为什么以‘w'形式打不开文件不能新建一个文件就退出了???
#include<stdio.h>#include<stdlib.h>
int main()
{
char c[7];
int i=0,a;
FILE*fp;
if ((fp = fopen("sc.dat", "w")) == NULL);
{
printf("error\n");
exit(0);
}
printf("输入一些字符:\n");
while ((a = getchar()) != '\n')
c[i++] = a;
for (i = 0; i < 7; i++)
{
if (c[i] >= 'a'&&c[i] <= 'z')
c[i] = c[i] - 32;
}
for (i = 0; c[i] != '!'; i++)
{
fputc(c[i], fp);
printf("%c", c[i]);
}
printf("\n");
fclose(fp);
return 0;
}