I am using fgets to read words line by line, however using fgets I always get the extra '\n' in each line.. how do I eliminate it?
say I have this list:
Apple
Bubble
Man
Zebra
then I use fgets, I get Apple\n, how do I get Apple only?
Printable View
I am using fgets to read words line by line, however using fgets I always get the extra '\n' in each line.. how do I eliminate it?
say I have this list:
Apple
Bubble
Man
Zebra
then I use fgets, I get Apple\n, how do I get Apple only?
you do not check return value of fgets before using it
you do not check return value of malloc before using it
you do not free allocated memory
you casting malloc: FAQ: Casting malloc?
sorry I just changed my question
You really have to study FAQ before asking futher questions...Quote:
I am using fgets to read words line by line, however using fgets I always get the extra '\n' in each line.. how do I eliminate it?
FAQ > How do I... (Level 1) > Get a line of text from the user/keyboard (C)