发布网友 发布时间:2022-04-21 07:44
共3个回答
热心网友 时间:2022-06-18 18:54
#include
#include
#include
void
main()
{
file
*fp;
char
buf[3][1024];
char
*input1=buf[0],*input2=buf[1],*save=buf[2];
printf("请输入密码:\n");
scanf("%s",input1);
fp=fopen("code.txt","w");
//以读写方式打开code.txt文件,如果没有文件就建立这个文件
fputs(input1,fp);
//将save里边的字符窜(即密码)写入code.txt文件中
printf("请再输入密码:\n");
scanf("%s",input2);
fclose(fp);
fp=fopen("code.txt","r");
fgets(save,1024,fp);
fclose(fp);
if(strcmp(input2,save)==0)
//string.h
里边的函数
printf("success\n");
else
printf("error\n");
}
热心网友 时间:2022-06-18 18:55
#include <stdio.h>
#include <string.h>
int main(void)
{
FILE * file1= fopen("ku.txt","r");
char content[256];
while(fscanf(file1,"%256[^\n]\n",content){
if (strstr(content,"question")){
FILE * file2= fopen("test.txt","w");
fprintf(file2,content);
fscanf(file1,"%256[^\n]\n",content);
fprintf(file2,content);
fscanf(file1,"%256[^\n]\n",content);
fprintf(file2,content);
fscanf(file1,"%256[^\n]\n",content);
fprintf(file2,content);
fscanf(file1,"%256[^\n]\n",content);
fprintf(file2,content);
fclose(file2);
break;
}
}
fclose(file1);
}
热心网友 时间:2022-06-18 18:55
太麻烦了