I just tried to print the String which I have received through scanf
function and I have set the loop to process further until I press the 0
to terminate.
First I have entered the single string, it was normally printed, but another time I have entered three strings => Name1 Name2 Name3
--> three strings were printed automatically like I mentioned below after the code
Program:
#include <stdio.h>
int main()
{
int i;
do {
char str[20];
printf("\nEnter the String: ");
scanf("%s", str); // String input
printf("The String is %s", str); // Print the String
printf("\n\nEnter the Number 1 to restart and 0 to terminate: "); //Input for loop
scanf("%d", &i);
} while (i != 0); // while loop
return 0;
}
Output console Screen:
Enter the String: Name
The String is Name
Enter the Number 1 to restart and 0 to terminate: 1 // Normally printed
// I don't what is happening by Entering three strings with space (Below Mentioned)
Enter the String: Name1 Name2 Name3
The String is Name1
Enter the Number 1 to restart and 0 to terminate:
Enter the String:
The String is Name2
Enter the Number 1 to restart and 0 to terminate:
Enter the String:
The String is Name3
Enter the Number 1 to restart and 0 to terminate: 0
...Program finished with exit code 0 Press ENTER to exit console.