-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathStringDemo.c
24 lines (23 loc) · 884 Bytes
/
StringDemo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/******************************************************
* File : StringDemo.c
* Description : C Program to read and write stings
* Author : Sarju S
* Version : 1.0
* Date : 18/08/2021
* ***************************************************/
#include<stdio.h>
int main(){
char myFirstString[10],mySecondString[20],myThirdString[20];
printf("\nEnter your first string:");
scanf("%s",myFirstString);
printf("\nThe string input from user is: %s",myFirstString);
fflush(stdin);//To clear input buffer
printf("\nEnter the Second String:");
gets(mySecondString);
printf("\nThe string input from user using gets is: %s",mySecondString);
printf("\nEnter the Thrird String:");
scanf("%[^\n]", myThirdString);
printf("\nThe string input from user using scanf is:");
puts(myThirdString);
return 0;
}