GeeksforGeeks » Interview Questions
Microsoft Interview Question for Software Engineer/Developer (Fresher) about CPuzzles
(6 posts)-
char str[80]; strcpy(str,"junk"); scanf("%[^india]",str); printf("%s",str);What will be the output of this code snippet if the given
input is “Gujarat”? -
Guj
-
str will stop recording if any of the characters from i,n,d or a arrives in input.
Hence Guj
-
I have never seen a format specifier like [^xyz]. Can someone explain it? Or give me a link?
-
@Abhijeet,
[ ^xyz ] is used for filtering the input.
here whenever any of the characters x,y or z is inputted in the sequence of inputs,scanf will just discard them.i think u hve understood. -
@Aashish
Thanks man! Got it... Will try out a few programs to test this...
Reply
You must log in to post.