Saturday, 31 August 2013

C Programming - Reading from stdin and storing \n and whitespace

C Programming - Reading from stdin and storing \n and whitespace

I've been trying to use scanf to get input from stdin but it truncates the
string after seeing whitespace or after hitting return.
What I'm trying to get is a way to read keyboard input that stores in the
buffer linebreaks as well as whitespace. And ending when ctrl-D is
pressed.
Should I try using fgets? I figured that wouldn't be optimal either since
fgets returns after reading in a \n

No comments:

Post a Comment