I have 2 structs and a variable type Book
Book book_struct[100];
typedef struct Book{
int id;
char title[256];
char summary[2048];
int numberOfAuthors;
Author * authors;
};
typedef struct Author{
char firstName[56];
char lastName[56];
};
when i want to change the title of each book i do
//title
char *title_char=new char[parsedString[1].size()+1];
title_char[parsedString[1].size()]=0;
memcpy(title_char,parsedString[1].c_str(),parsedString[1].size());
strcpy(books_struct[z].title, title_char);
where parsedString is an array which contains the id,title,summary,number of authors and a firstname and lastname
and the above code works for title
but when i try to change the author firstname and lastname using the following code
//author firstname
char *author_fn_char=new char[parsedString[4].size()+1];
author_fn_char[parsedString[4].size()]=0;
memcpy(author_fn_char,parsedString[4].c_str(),parsedString[4].size());
strcpy(books_struct[z].authors->firstName, author_fn_char);
the program compiles and when i run it it says "Program not responding" as a windows error and closes...