scanf in C : Reading single line of text using "scanf" function

I have done it 4-5 years ago, that to read a whole line of text (including space) using scanf function.

When I was preparing for my exams, I went back to the old days of a “C” student. Nowadays I’m a bit used with C++. So I forgot the format specifier to specfy inside the scanf function. Finally my memory retrieved it back

Here’s it is:

char name[100];

printf(“Enter the name:”);
scanf(“%[^\n]“,name);

Something cool no?

View Commentsscanf in C : Reading single line of text using "scanf" function

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

blog comments powered by Disqus