请问C结构成员为什么无法直接赋值
p_book[n].sort = n+1 ;
这里指针指向结构第二元素了,可结构成员sort始终没有递增,“完整”程序在下边,还没写完,请大佬们指导指导还有哪写的不对
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXTITL 40
#define MAXBKS 10
struct book{
int sort; //序号
char title[MAXTITL]; //书名
char author[MAXTITL]; //作者
float value; //价格
};
char * s_gets(char * st,int n); //处理换行符
char menu(void);
void delete(struct book *,int);//删除
//void modify(struct book *); //修改
int add(struct book *,int ); //添加
int line(int );
int main(void)
{
struct book library[MAXBKS]; //结构数组
int count_1 = 0, count = 0;
char ch;
int index = 0,filecount = 0;
FILE * pbooks; //文件指针
int size = sizeof(struct book); //结构所占字节
if ((pbooks = fopen("/Users/wujiayi/Desktop/library.txt", "r+b")) == NULL)
{
fprintf(stderr, "Open file library.txt error\n");
exit(EXIT_FAILURE)