Click here to Skip to main content
15,938,848 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
char chTitle[MAX_PATH];
//gets(chTitle);
scanf("%[^\t\n]s", &chTitle);



above code not working....scanf is just skipping.... any clue...I want to read string with space in chTitle
Posted
Comments
Member 2954534 4-Dec-12 3:15am    
What exactly do you mean by "scanf is just skipping"? Doesn't it let you enter characters? Isn't there anything in chTitle?

scanf format specifiers don't support regular expressions (or whatever you wrote), see the documentation[^].
 
Share this answer
 
See here[^], scanf() format specifications do not take regular expressions.
 
Share this answer
 
Comments
Member 2954534 4-Dec-12 4:12am    
That isn't meant to be a regular expression. See here: http://msdn.microsoft.com/en-us/library/xdb9w69d%28v=vs.71%29.aspx. It's a delimiter list.
What about
"%[^\t\n]"
?
 
Share this answer
 
In addition to solution 1 you must not use the '&' with chTitle. scanf expects char *, not char **. At least my gcc complains when I use the '&'.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900