C Reading String with Spaces

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

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];

Enter the name : ");

printf ("
Name of Student : %s ",name);

Output of this Block :

Enter the Name : Don Bosqo
Name of Student : Don Bosqo