How do I know about a failure? And how can feof help me recover?
On both counts, I assume. Why is linking necessary if includes still work?
Yes, the garbage is present directly after the call to fgets... (A statement is executed after I proceed to the next stement with next.)Are you only referring to checks for NULL?Code:Breakpoint 2, readLine (length=32, stream=0x804b008) at main.c:9 9 char *result = malloc(length * sizeof(char)); (gdb) next 10 fgets(result, length, stream); (gdb) print result $14 = 0x804b358 "" (gdb) next 11 char *last = &result[strlen(result) - 1]; (gdb) print result $15 = 0x804b358 "\201\004\b\024\201\004\b\023" (gdb) next 12 if(*last == '\n'){ (gdb) next 15 return result; (gdb) next 16 }



LinkBack URL
About LinkBacks




