Method 01:
To take input string of a word we use
char str[30] ;
scanf("%s",str) ;
printf("%s",str) ;
This function takes input of a word but not a line .
Example -
Input- I love dates.
Outpu - I
Method 1.1 :
To take a input of a line until a new line we use -
char str[30] ;
scanf("%[^\n]s",str) ;
printf("%s",str) ;
Input- I love dates.
Output- I love dates.
Method 1.2 :
We can also use -
fgets(str,sizeof(str),stdin); // To take input
fputs(str,stdout) ;//To get output
Input - I love dates
Output - I love dates
Here puts function works like print function .
Top comments (0)