int main()
{
char s[100];
char s1[] ={"Hello, World!"};
scanf("%[^\n]%*c", s); // The statement that we are interested in//
printf("%s",s1);
printf("\n");
printf("%s",s);
return 0;
}
Asked
Active
Viewed 140 times
-2

Some programmer dude
- 400,186
- 35
- 402
- 621

predator
- 1
-
5Perhaps [a decent `scanf` reference](https://en.cppreference.com/w/c/io/fscanf) might be helpful? – Some programmer dude Dec 23 '20 at 16:26
1 Answers
1
There are already some post about this argument, such as this. By the way:
with %[^\n]
you are taking input until a newline isn't encountered. With %*c
you take the newline character and then discard it (this is useful when you are using fgets after scanf).