日期:2014-05-16 浏览次数:20675 次
int main(){ FILE *fp; char tmp[100]; if((fp=fopen("/root/conf/test.txt","rb+"))==NULL) { printf("Cannot open file strike any key exit!"); return -1; } rewind(fp); while(!feof(fp)) { memset(tmp,0,100); fgets(tmp,100,fp); int len = strlen(tmp); char buffer_copy[100]; memset(buffer_copy,0,100); strcpy(buffer_copy,tmp); buffer_copy[len-1]='\0'; printf("name:%s,%d\n",buffer_copy,len); FILE *stream; stream=fopen(buffer_copy,"rb"); perror("fopen"); fclose(stream); } return 0; }