C programming code
To input a string we use scanf function.
C programming code
Input string containing spaces
Note that scanf can only input single word strings, to receive strings containing spaces use gets function.
#include <stdio.h> int main() { char array[20] = "Hello World"; printf("%s\n",array); return 0; }
#include <stdio.h> int main() { char array[100]; printf("Enter a string\n"); scanf("%s", array); printf("You entered the string %s\n",array); return 0; }
#include <stdio.h> int main() { char a[80]; gets(a); printf("%s\n", a); return 0; }
No comments:
Post a Comment