Another way of getting the same functionality (avoiding feof())
#include <stdio.h>
int main() {
FILE *infile;
char buffer[100];
char c, r1[100], r2[100], r3[100];
if (!(infile=fopen("tester.txt", "r")))
return 1;
while (fgets(buffer, 100, infile)) {
sscanf(buffer, "%c %s %s %s", &c, r1, r2, r3);
printf("%c %s %s %s\n", c, r1, r2, r3);
}
fclose(infile);
return 0;
}
@Pushparaj, you should note the use of "int main() ... return 0" and
"\n" in printfs by both Mohit and me.
SB
--
l...@iitd - http://tinyurl.com/ycueutm
To unsubscribe, reply using "remove me" as the subject.