我写的C语言程序,为什么运行完之后会出现
null pointer assignment?请指点!
#include <stdio.h>
#include <io.h>
main()
{
int ch_year,ch_mon,ch_day;
char ch;
FILE *fp;
struct ftime ft;
if((fp=fopen("C:\\HP\\Support\\DMIinfo.INI","r"))==NULL)
{
printf("\nCan not open \"C:\\HP\\Support\\DMIinfo.INI.\"\n");
exit(0);
}
getftime(fileno(fp),&ft);
ch_year=ft.ft_year;
ch_mon=ft.ft_month;
ch_day=ft.ft_day;
printf("File Date: %d/%02d/%02d \n", ch_year+1980,ch_mon,ch_day);
fgets(ch,10,fp);
printf("%s",ch);
fclose(fp);
getch();
}
----------------解决方案--------------------------------------------------------
ch是字符,您却把它当成字符串操作。
----------------解决方案--------------------------------------------------------
我写的C语言程序,为什么运行完之后会出现
null pointer assignment?请指点!
#include <stdio.h>
#include <io.h>
main()
{
int ch_year,ch_mon,ch_day;
char ch;
FILE *fp;
struct ftime ft;
if((fp=fopen("C:\\HP\\Support\\DMIinfo.INI","r"))==NULL)
{
printf("\nCan not open \"C:\\HP\\Support\\DMIinfo.INI.\"\n");
exit(0);
}
getftime(fileno(fp),&ft);
ch_year=ft.ft_year;
ch_mon=ft.ft_month;
ch_day=ft.ft_day;
printf("File Date: %d/%02d/%02d \n", ch_year+1980,ch_mon,ch_day);
fgets(ch,10,fp);
printf("%s",ch);
fclose(fp);
getch();
}
问题就是有颜色那了
----------------解决方案--------------------------------------------------------