C Reading String with Spaces : Using scanf()
Reading String with spaces by using scanf
Note that -
- scanf with %s accepts only String which does not contain whitespaces (blanks/space)
- C Supports the ‘ special Edit set Conversion Code ‘ , by using this method we can accept the line of String with spaces using scanf
- 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