How to get input with spaces in C language?
/*
Example: read string separated by space char in C language
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
char str[100];
scanf("%[^\n]%*c", str);
printf("%s",str);
return 0;
}uoSrce:www.lautturi.comexample of output:
hello lautturi 《-- user input hello lautturi Process returned 0 (0x0) execution time : 6.886 s Press any key to continue