读取文件,输出单词
2011-10-13 21:50
274 查看
#include <iostream> #include <string> using namespace std; int main() { FILE *fd; fd = fopen("f:\\text.txt","rb"); if(!fd) { printf("read file error!"); return 0; } printf("read file success!\n"); char buf[10]; char* str; while(!feof(fd)) { fscanf(fd,"%s",buf); cout << buf << endl; if(!strcmp(buf,"zhouqiang")){ cout << "OK"<< endl; cout << strlen(buf) << endl; str = new char[strlen(buf)+1]; strcpy(str,buf); cout << "str: " << str << endl; } } fclose(fd); return 1; }
相关文章推荐
- java 读取键盘输入到txt文件,统计每个单词出现的次数并输出
- C++实现读取文件,输出单词
- python读取文件里的单词,统计词频,输出到文件
- Python读取英文文件并记录每个单词出现次数后降序输出示例
- Java实现读取键盘输入保存到txt文件,再统计并输出每个单词出现次数的方法
- 从一个名为 in_file.txt 的文本文件中读取单词,然后把每个词写到一个名为out_file.txt的输出文件中 并且每个词之间用空格分开
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- 文件下载:POI读取word或Excel,修改内容后以流的形式输出到前端
- 《黑马程序员》 IO之读取文件中的信息输出到控制台显示
- 文件读取输出
- Shell根据给定路径读取其中的文件并输出到指定的路径
- java 按行读取文件并输出到控制台的方法
- 测试sq3数据库,读取数据库把内容输出到csv文件,附上输出到excel方法
- python工具 - 读取文件的部分指定内容并输出到外置窗口
- 文件中有姓名,分数两列,读取并按分数排序输出
- 如何解决读取到文件末尾时碰到EOF导致的重复输出或者无用输出
- 二进制文件读取输出text进行比对
- java学习笔记 读取pdf文件并写成txt文件输出
- R从文件中读取数据,输出文件
- 读取一个文本文档,例如有1~10行,要求按10~1行的顺序输出.并保存予原文件