user input in c string code example
Example 1: getting string input in c
#include
#include
void main(){
chat sam[10];
clrscr();
printf("ENTER STRING NAME :");
gets(s);
printf("STRING :%s",s);
getch();
}
Example 2: input output string in c
#include
#include
#include
#include
int main()
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
char ch;
char s[100];
char p [100];
scanf("%c", &ch);
scanf("%s", s);
scanf("\n");
scanf("%[^\n]%*c", p);
printf("%c \n", ch);
printf("%s \n", s);
printf("%s", p);
return 0;
}