int main() {
char a[100];
printf("\nEnter 1st Sentence : ");
scanf("%[^\n]", a);
printf("\nSentence 1 : %s", a);
printf("\nEnter 2nd Sentence : ");
scanf("%[^\n]", a);
printf("\nSentence 2 : %s", a);
return 0;
}
My output:
Enter 1st Sentence : Testing 1st Sentence
Sentence 1 : Testing 1st Sentence
Enter 2nd Sentence :
Sentence 2 : Testing 1st Sentence
I'm basically checking %[^\n]. When I type the 1st sentence and press "Enter" key, it prints "Enter 2nd Sentence : " and then "Sentence 2 : " and then it prints the 1st sentence.