C language tutorial -15 string input and output
Char, we said this is a character. And a string is an array of chars.
Char [] s = “hello”; // declare + initialize
char a[100];
Input method 1: scanf(“%s”,&a); Method 2: gets(a);
Printf (“%s”,a); Method 2: puts(a);
#include <stdio.h>
char a[100];
int main (a)
{
scanf("%s",&a);
printf("%s",a);
return 0;
}
Copy the code
Both run with the same result: