#include<stdio.h>
void main()
{
char para[100];
printf("Enter Paragraph : ");
scanf("%[^\t]",para);
printf("%s",para);
}Output :[Press Tab to Stop Accepting Characters ]
Enter Paragraph : C Programming is very easy to understand C Language is backbone of C++ Language
How ?
scanf("%[^\t]",para);- Here scanf will accept Characters entered with spaces.
- It also accepts the Words , new line characters .
- [^\t] represent that all characters are accepted except tab(\t) , whenever \t will encountered then the process of accepting characters will be terminated.
- Paragraph Size cannot be estimated at Compile Time
- It’s vulnerable to buffer overflows.
//------------------------------------
// Accepts only 100 Characters
//------------------------------------
scanf("%100[^\t]",para);
Tags / Keywords : | Accepting Strings, Reading Line containing Space, scanf, string with spaces, Strings



1 Comment:
cool
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