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?
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?
Last edited by -EquinoX-; 05-03-2008 at 11:58 PM.
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?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
sorry I just changed my question
You really have to study FAQ before asking futher questions...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)
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler