Code:#include <stdio.h> #include <stdlib.h> #include <string.h> int main( int argc, char **argv) { char *input = argv[0]; FILE *fp; if ( (fp = fopen(input,"r")) == 0 ){printf("open '%s' error.\n",input); exit(0);} int i = 0; while( feof(fp) == 0 ) { char buf[100]; fgets(buf,100,fp); if ( strlen(buf) >= 2 ) ++i; printf("%s\n",buf); } printf("line number:%d\n",i); return 0; }



LinkBack URL
About LinkBacks



