The scanf() function consider the jack and Jill as 3 strings, whereas gets() considers as single string. In case to scan total string using scanf(), then it should be scanf(“%s%s%s”, a,b,c); here a,b,c are three arrays.
The printf() and puts() is work in similar way. All I/O functions take first byte address (base address of array) as argument and prints the given string using pointer.
#include<stdio.h>
#include<string.h>
int main()
{
char name[30];
printf(“Enter name: “);
gets(name); //Function to read string from user.
printf(“Name: “);
puts(name); //Function to display string.
return 0;
}
Enter name: Free Time Learning
Name: Free Time Learning