在文本文档中查找数据的应用---C语言+dos
目的是搜索一个名称是否在文档中存在,存在的话显示出来。不是完全用C语言,结合一点批处理技术,实现起来比较简单
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<string.h>
int main()
{
char string_to_be_find[100];
while(true)
{
char find[100]="find /I d:\\查找题目专用文档--随时更新--ma6174.txt \"";
printf("\t\t题目查找专用程序 BY ma6174\n\n");
printf("请输入要查找的题目名:");
gets(string_to_be_find);
if(strlen(string_to_be_find)==0)
{
system("cls");
continue;
}
strcat(find,string_to_be_find);
strcat(find,"\"");
system(find);
printf("是否将题目名加入文档?(y/n)");
char choice=getche();
if(choice=='y'||choice=='Y')
{
char write_in_file[100]="echo ";
strcat(write_in_file,string_to_be_find);
strcat(write_in_file," >>d:\\查找题目专用文档--随时更新--ma6174.txt");
system(write_in_file);
printf("\n\n题目名已经写入!");
Sleep(2000);
}
system("cls");
}
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<string.h>
int main()
{
char string_to_be_find[100];
while(true)
{
char find[100]="find /I d:\\查找题目专用文档--随时更新--ma6174.txt \"";
printf("\t\t题目查找专用程序 BY ma6174\n\n");
printf("请输入要查找的题目名:");
gets(string_to_be_find);
if(strlen(string_to_be_find)==0)
{
system("cls");
continue;
}
strcat(find,string_to_be_find);
strcat(find,"\"");
system(find);
printf("是否将题目名加入文档?(y/n)");
char choice=getche();
if(choice=='y'||choice=='Y')
{
char write_in_file[100]="echo ";
strcat(write_in_file,string_to_be_find);
strcat(write_in_file," >>d:\\查找题目专用文档--随时更新--ma6174.txt");
system(write_in_file);
printf("\n\n题目名已经写入!");
Sleep(2000);
}
system("cls");
}
}
博主ma6174对本博客文章(除转载的)享有版权,未经许可不得用于商业用途。转载请注明出处http://www.cnblogs.com/ma6174/
对文章有啥看法或建议,可以评论或发电子邮件到ma6174@163.com