Я пишу код, используя структуры, которые будут читать текстовый файл с данными о книге. Название, автор, издатель, жанр т.д. ...Что это значит: '=': левый операнд должен быть l-значением?
мой файл заголовка выглядит следующим образом:
typedef struct book{
char name[NAME_LENGTH];
char authors[AUTHORS_NAME_LENGTH];
char publisher[PUBLISHER_NAME_LENGTH];
char genre[GENRE_LENGTH];
int year;
int num_pages;
int copies;
}book;
typedef struct library
{
book books[BOOK_NUM];
}library;
typedef char* string;
код:
if (NULL == (incoming_books = fopen(".\books.txt", "r")))
{ /* opening file for reading */
/*printf("Error opening file"); write to file*/
exit(1);
}
while (!feof(incoming_books))
{
fgets(line,200,incoming_books);//copies one line, assuming no longer than 200 chars
idx_helper = strchr(line, '$');//finds '$' index, attribures are seperated by "$$$"
index = (int)(idx_helper - line);// cast index into int
char_num = index;
if (NULL != memcpy(temp_string, line, char_num))//copies string (name)
temp_book->name = *temp_string;
index += 3; // incrementing index by 3
idx_helper = strchr(&line[index], '$'); // same for authors
index = (int)(idx_helper - &line[index]);
char_num = index;
if (NULL != memcpy(temp_string, &line[index], char_num*sizeof(char)))
temp_book->authors = *temp_string;
}
и так далее для каждой книги атрибута
Я получаю две ошибки: 1. Ошибка 7 ошибки C2106: '=': левый операнд должен быть l-значением , который указывает на строки temp_book-> name = * temp_string; и temp_book-> authors = * temp_string; 2. IntelliSense: выражение должно быть модифицируемым значением , которое указывает на одинаковые строки.
может быть проблемой указателя?
Совет: использовать условия йоды, естественно, не найдет его читателями. –