输入保存
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#include<iostream.h>
#include<windows.h>
void shuru()
{ FILE*fp;
char filename[20];
int i;
i=0;
char s[1000];
printf("请输入所用的文件名:");
scanf("%s",filename);
if ((fp=fopen(filename,"w"))==NULL);
{ printf("无法打开文件\n");
exit(0);
}
printf("请输入字符:");
scanf("%c",s[0]);
while (s[i] !='#')
{ scanf("%c",&s[++i]);
fprintf(fp,"%c",s[i]);
}
return 0;
}
int main()
{ int x;
loop:printf("\n请输入需要操作(0退出程序):\n\n");
printf(" 1.输入保存 2.最长不重复子串 3.最长回文串 4.字符概率\n\n");
printf(" 5.哈夫曼编码 6.二进制文件 7.二进制解码 8.对比\n\n");
scanf("%d",&x);
switch(x)
{
case 1: shuru();goto loop;
// case 1:minganchuan(a,n);goto loop;
// case 2:buchongfu(a,n);goto loop;
// case 3:huiwen(a,n);goto loop;
// case 4:gailv(a,n);goto loop;
// default:printf("wrong!");
}
}
c(12) : error C2143: syntax error : missing ';' before 'type'
F:\VC6.0完整(www.)\MyProjects\practice\22\2.c(21) : error C2065: 's' : undeclared identifier
F:\VC6.0完整(www.)\MyProjects\practice\22\2.c(21) : error C2109: subscript requires array or pointer type
F:\VC6.0完整(www.)\MyProjects\practice\22\2.c(22) : error C2109: subscript requires array or pointer type
F:\VC6.0完整(www.)\MyProjects\practice\22\2.c(23) : error C2109: subscript requires array or pointer type
F:\VC6.0完整(www.)\MyProjects\practice\22\2.c(23) : error C2102: '&' requires l-value
F:\VC6.0完整(www.)\MyProjects\practice\22\2.c(24) : error C2109: subscript requires array or pointer type
F:\VC6.0完整(www.)\MyProjects\practice\22\2.c(26) : warning C4098: 'shuru' : 'void' function returning a value
执行 cl.exe 时出错.
2.obj - 1 error(s), 0 warning(s)
为什么会出现这么多错误