The gets() function obtains a character from the keyboard. The parameter inside is the character pointer char *s
So gets(s); is correct; in addition, char s[5]; It is an array of 5 elements that defines char. The first element is represented as s[0]
. Then its address form is &s[0], so gets(&s[0]); is also correct. .
scanf(foramt,parameter pointer);
The first parameter is the input format such as "%d". Enter an integer data
The second parameter It is a variable pointer
So when defining the array char s[5];
The address of the second element of the array is expressed as &s[1], which can also be written as (s+1); so When int i=1;
It is correct to have scanf("%s",s+1);
Because the two parameters require the use of pointer types and s[1 ] is not a pointer type so it is wrong