Edit Set


This will be great useful in strings.You can specify the characters you want to include or exclude in C.This will work with scanf.
Include set:

means it will read all the characters between a to z and if other character in encountered, it will stop reading the variable.
Ex:if the input is adithyaU, then the value of string variable 'a' will be adithya only.

You can specify the individual chars also
will read only the chars a,d,i
if input adithya then the value of 'a' will be adi only.

Special characters and white spaces may also be included in the edit set

will read only chars *

Exclude set

means it wil read all the characters until t is encountered

Here all the chars means special chars and white space chars are also included.That means draw back of scanf over gets can be overcome by using exclude set

if i input adithya then the value of 'a' will be adi

means no Capital's are allowed

read ALL chars until enter key is encountered(Function as gets())

The use of edit set is illustrated in the following program:

Write a c program which makes scanf to accept the special as well as white space chars
Example Program:

void main()
char str[100];
printf("Enter any string\n");
scanf("%[^\n]s",str); //<----- Imp step--------
printf("\n You entered string %s \n",str);

About This Blog

There is something for everyone. !! A tech blog on various topics. Let it be devops, programming etc; we have it all covered here in layman terms :)

Total Pageviews

Back to TOP