FREE TUTORIALS ON C programming

Sunday, January 26, 2014

#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
          
          }
          
12:21 AM   Posted by Unknown with No comments

0 comments:

Post a Comment

Bookmark Us

Delicious Digg Facebook Favorites More Stumbleupon Twitter

Search