Advertisement
hasegawa

csvread

Sep 20th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include    <stdio.h>
  2. int main(int argc, char *argv[])
  3. {
  4.     int r,g,b;
  5.     int count;
  6.     FILE *fp;
  7.     float x,y,z;
  8.  
  9.     if(argc!=2)
  10.     {
  11.         fprintf(stderr,"Usage:%s(1)InputFileName.txt\n",argv[0]);
  12.  
  13.         return 0;
  14.     }
  15.  
  16.     if((fp = fopen(argv[1],"r"))==NULL)
  17.     {
  18.         printf("THE file can't be opend. The program is exit.\n");
  19.  
  20.         return 0;
  21.     }
  22.  
  23.     count=0;
  24.  
  25.     while (fscanf(fp,"%f,%f,%f,%d,%d,%d",&x,&y,&z,&r,&g,&b)!=EOF)
  26.     {
  27.         printf("%f,%f,%f,%d,%d,%d\n",x,y,z,r,g,b);
  28.  
  29.         count=count+1;
  30.     }
  31.  
  32.     printf("total=%d\n",count);
  33.  
  34.     fclose(fp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement