文件中检索字符串

 1 #define  _CRT_SECURE_NO_WARNINGS
 2 #include<stdio.h>
 3 #include<stdlib.h>
 4 
 5 /*
 6     find [/v] [/c] [/n] [/i] ["string"[[drive:] [path] filename[...]]
 7     /v  显示所有未包含指定字符串的行
 8     /c  仅显示包含字符串的行数
 9     /n  显示行号
10     /i  搜索字符串时忽略大小写
11     "string"  指定要搜索的字符串
12     [drive:] [path] filename 指定要搜索的文件
13 */
14 
15 void main()
16 {
17     char str[30] = "你好";// 要查找的字符串
18     char path[50] = "C:\\Users\\Administrator\\Desktop\\test.c";
19     char cmd[100];
20     sprintf(cmd, "find /n /i \"%s\" \"%s\" ",str,path);
21     system(cmd);
22     system("pause");
23 }

运行结果:

posted on 2015-05-25 14:42  Dragon-wuxl  阅读(143)  评论(0)    收藏  举报

导航