#include<stdio.h>
int main()
{
char str[15]; //string variable declaration
scanf("%s",str); //scanf read a string from keyboard until first white space
printf("the value of str is %s\n",str); //printf prints the string to the console
fflush(stdin); //flushes the carriage return not read by scanf
scanf("%[^\n]s",str); //read the str including the white space
printf("the value of str is %s\n",str);
fflush(stdin); //flushes the carriage return not read by scanf
getchar(); //waits for the user to press a character
}
int main()
{
char str[15]; //string variable declaration
scanf("%s",str); //scanf read a string from keyboard until first white space
printf("the value of str is %s\n",str); //printf prints the string to the console
fflush(stdin); //flushes the carriage return not read by scanf
scanf("%[^\n]s",str); //read the str including the white space
printf("the value of str is %s\n",str);
fflush(stdin); //flushes the carriage return not read by scanf
getchar(); //waits for the user to press a character
}
0 comments:
Post a Comment