View Single Post
Join Date: Jan 2008
Posts: 6
Reputation: Matt You is an unknown quantity at this point 
Solved Threads: 0
Matt You Matt You is offline Offline
Newbie Poster

Re: scanning char array for \0 problem

 
0
  #5
Jan 22nd, 2008
Originally Posted by Duoas View Post
Ah, the loop ends at the space because the string ends at the space. scanf stops reading input at spaces. So when you enter "1234 432" the userString gets "1234", and " 432" is left waiting to be read.

If you want to get a string from the user try using fgets().

Good luck.
Thank you! I never would have figured that out. It all works the way it should now.
Reply With Quote