1.

What is scanset?Mention the syntax of a scanset and explain its use with the help of an appropriate example?

Answer»

Answer:

scanf family functions support scanset specifiers which are REPRESENTED by %[]. Inside scanset, we can specify single character or RANGE of characters. While processing scanset, scanf will process only those characters which are PART of scanset. We can DEFINE scanset by putting characters inside squre brackets. PLEASE note that the scansets are case-sensitive.

Explanation:

#include

int main(void)  

{  

   char str[128];

   printf("Enter a string: ");  

   scanf("%[A-Z]s", str);  

   printf("You entered: %s\n", str);  

   return 0;  

}

input : Enter a string: working

output : You entered: working



Discussion

No Comment Found