关于文件读取显示时,编译正常,程序却半路停止运行的问题
#include<stdio.h>#include<stdlib.h>
#include<string.h>
struct career
{
char c_num[20];
char c_nam[20];
char c_car[20];
};
void app(void)
{
FILE *fp;
struct career *p;
if((fp=fopen("car.text","r"))==NULL)
{
printf("打开失败!\n");
exit(1);
}
while(!feof(fp))
{
fscanf(fp,"%s\n",p->c_num);
fscanf(fp,"%s\n",p->c_nam);
fscanf(fp,"%s\n",p->c_car);
printf("%s\n%s\n%s\n",p->c_num,p->c_nam,p->c_car);
}
fclose(fp);
}
int main(void)
{
app();
return 0;
}
如何解决???