Skip to main content

Timeline for reading string from a file in c

Current License: CC BY-SA 3.0

7 events
when toggle format what by license comment
S Mar 2, 2013 at 9:43 history suggested Henk Langeveld CC BY-SA 3.0
Fix buffer overflow
Mar 2, 2013 at 9:41 review Suggested edits
S Mar 2, 2013 at 9:43
Mar 2, 2013 at 9:30 comment added pmg You can read the input in a single instruction (I like it better): if (fscanf(fp3, "%d%d%d%s", &x, &y, &z, cs) != 4) /* error */;
Mar 2, 2013 at 9:07 comment added Jens Note that you should test the return value from fscanf. It it is not 4 then some of the conversions failed or the end of file was reached.
Mar 2, 2013 at 8:36 comment added dudeofea using strcmp. Although you'll have to do some pointer voodoo on the char array. like, use &cs[0] instead of cs. normal strings which are char* are fine. So: strcmp(str1, &cs[0]);
Mar 2, 2013 at 8:22 comment added Orel Eraki I dont think 'cs' should be with &, it is an array.
Mar 2, 2013 at 8:21 history answered Michał Kwiatkowski CC BY-SA 3.0