#include
#include
void Input()
{
FILE *fp;
if((fp = fopen("file1.txt","w")) ==NULL)
{
exit(1);
}
char a;
printf("输入一串字符,以$结束\n");
while(scanf("%c",&a) && a!= '$')
{
fputc(a,fp);
}
fflush(stdin);
fclose(fp);
}
int Find(char c)
{
FILE *fp;
int flag = 0;
if((fp = fopen("file1.txt","r")) ==NULL)
{
exit(1);
}
while(!feof(fp))
{
char ch = fgetc(fp);
if(ch == c)
flag = 1;
}
if(flag == 1)
{
printf("find!\n");
}
else
printf("not find!\n");
fclose(fp);
return 0;
}
int main()
{
char cha;
Input();
printf("输入要查找的字符:");
scanf("%c",&cha);
Find(cha);
return 0;
}
看看是不是你要的