Here’s an example program that accepts a string through the keyboard using the gets()
function:
#include <stdio.h>
int main() {
char str[100];
printf("Enter a string: ");
gets(str);
printf("You entered: %s", str);
return 0;
}
In the above program, an array of characters str
is declared to hold the input string. The gets()
function is used to read the string from the keyboard. The entered string is then displayed using the printf()
function.
Thanks
Write a program to accepts string through the keyboard using the gets() fuction.