to supress newline we use %[^\n].can you suggest what should be the format to skip blank in the input,ie if we have to input "hallo stackflow".i know fgets and gets but i dont want to use them ,they are creating problem.
+1
A:
Put a blank in the scanf format; that suppresses whitespace.
Charlie Martin
2009-04-23 15:28:48
A:
I think you mean "include whitespace". Use:
#define str(x) #x
#define xstr(x) str(x)
/* ... */
char buf[ SIZE + 1 ] = "";
int rc = scanf("%" xstr(SIZE) "[^\n]%*[^\n]", buf);
/*you may need the return value later on, if reading
in multiple strings with whitespaces in a loop */
if (!feof(stdin))
getchar(); /* consume newline */
dirkgently
2009-04-23 15:36:29