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?
This is a discussion on reading words line by line from a file within the C Programming forums, part of the General Programming Boards category; I am using fgets to read words line by line, however using fgets I always get the extra '\n' in ...
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?
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.
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)
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.