To get a statement from the user input in the array char s[100]:
-
gets( s[100] );
-
gets( s[] );
-
gets( s );
-
none of the above
The function gets() expects a pointer to a character array (char *). Since the array name s decays to a pointer to its first element, gets(s) is the correct syntax. Option A passes an int, and B uses invalid empty bracket syntax.
To get a statement from the user input in the array char s[100], the correct option is C. gets( s );
Explanation:
A. gets( s[100] ); - This option is incorrect because s[100] is accessing the 100th element of the array s, which is not a valid argument for the gets() function.
B. gets( s[] ); - This option is incorrect because s[] is not a valid argument for the gets() function. The [] should be followed by an index or a range of indices to specify which elements of the array to access.
C. gets( s ); - This option is correct because s is the correct argument to pass to the gets() function. It allows the user to input a string and store it in the array s.
D. None of the above - This option is incorrect because option C, gets( s );, is the correct option to get a statement from the user input in the array char s[100].
Therefore, the correct answer is C.