How to read string with space in C program?

preview_player
Показать описание
Ever wondered why space is not read in your C program?

We use %s modifier is scanf() but fails to read space withing two words. How to fix this issue?

Well here is a tutorial on how to read any string with space included in C program.

C language has a technique to read space within text using a scanset character.

%[^\n] is scanset character in C language. \n is represent newline character and %[^\n]s means read everything until newline is found.

Simple.

Thanks for watching.

Please like, share, subscribe the channel. Once again, do please ask questions related with programming or web development and I will answer them as well.
Рекомендации по теме
Комментарии
Автор

That's great, I'm stuck with this for 3 day. And now my code is work coz of fflush(stdin) that you showed us.

dylytithsambath
Автор

you are a HERO!! i've been having the problem with using scanset and it skipping over other scanfs!! THNAK YOU SO MUCH❤️✨

-exe
Автор

Very Nice super .
I understand perfect.
Thank you

kalaipradeep
visit shbcf.ru