program to input a string and display it

// program to input string and display it
void main()
char a[20];
printf(“enter a string\n”);
gets(a); // we can also use scanf("%[^\n]",a);
puts(a); // we can also use printf("the string =%s",a);

1)gets() function is used to input a string and
puts() is used to display that string.
may be with space or without space.
2) If we use scanf("%[^\n]",a) then it accepts space for a string but if we use scanf("%s",a) then it does not accept string with space.so better to use gets or scanf("%[^\n",a);