#include<stdio.h>
#include<stdlib.h>
void init_rec(day_record *arr[],FILE *file)
{
char temp[80];
int index=0;
while((fscanf(file,"%s",temp))!=EOF)
{
arr[index]=NULL;
arr[index]=(day_record * )malloc(sizeof(day_record));
if(arr[index]==NULL)
{
printf("结构地址分配错误\n");
exit(1);
}
replace(',',' ',temp);
inputrc(arr[index],temp);
index++;
}
}
在gcc中编译 总是提示错误发生在void init_rec(day_record arr[],FILE *file)这一行
*错误内容是 pay.c:6: 错误:expected ‘)’ before ‘*’ token **
结构体是这么写的
//每日记录临时存储结构
typedef struct day_record
{
int worker_nu;
char date[DATE_LEN];
char * loca;
int work_nu;
char * worker[WORK_LEN];
} day_record;
调用是这样的
#include<stdio.h>
#include<stdlib.h>
#include"pay.h"
#include"pay.c"
int main()
{
FILE * fp;
day_record * record[31];
fp = fopen("pay","r");
if(fp==NULL)
{
printf("open failed\n");
exit(1);
}
init_rec(record,fp);
putdr(record[0]);
fclose(fp);
return 0;
}
想不明白是怎么回事 求指教 谢谢大家