Right Click to Search

Saturday, January 16, 2025

Reading String with spaces by using scanf


Reading String with spaces by using scanf
Note that -
  1. scanf with %s accepts only String which does not contain whitespaces (blanks/space)
  2. C Supports the ' special Edit set Conversion Code ' , by using this method we can accept the line of String with spaces using scanf
  3. It Reads wide verity of Characters including blank
Syntax :
scanf("%[^\n]", name );
Live Example : 
char name[100];
printf("\nEnter the name : ");
scanf("%[^\n]",name);
printf ("\nName of Student : %s ",name);
Output of this Block :
Enter the Name : Don Bosqo
Name of Student : Don Bosqo

Tags / Keywords : | , ,

Stumble
Delicious
Technorati
Twitter
Facebook

0 Comments:

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email

 

Learn C Programming Copyright © 2010 LKart Theme is Designed by Lasantha, Free Blogger Templates