Hi,
My C program prints the last line of text file twice. below is the part of
my code


void main(){
 char buffer[100];
  FILE *infile = NULL;
int start,end,cost;
char r1[100];
char r2[100];
char r3[100];
char c;

 infile=fopen("tester.txt","r");

  if (infile != NULL)
  {
    while (!feof(infile)) {
    fgets(buffer,100,infile);

    sscanf(buffer,"%c %s %s %s", &c,r1,r2,r3);
    printf("%c %s %s %s", c,r1,r2,r3);
    }

}
fclose(infile);
}


tester.txt

a 1 2  87
a 2 1  93
a 2 3  50
a 3 2  22


Thank you
Pushparaj Shetty D.
IIT Delhi

-- 
l...@iitd - http://tinyurl.com/ycueutm

To unsubscribe, reply using "remove me" as the subject.

Reply via email to