PhoenixZq
分享是一门艺术~~
#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;   
}  

  

posted on 2011-10-13 21:50  PhoenixZq  阅读(371)  评论(0编辑  收藏  举报