GeeksforGeeks » Interview Questions

Microsoft Interview Question for Software Engineer/Developer (Fresher) about CPuzzles

(6 posts)
  • Started 9 months ago by learner
  • Latest reply from Abhijeet

Tags:

  1. learner
    guest
    Posted 9 months ago #

        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”?

  2. Hackme
    Member
    Posted 7 months ago #

    Guj

  3. Shantanu
    guest
    Posted 4 months ago #

    str will stop recording if any of the characters from i,n,d or a arrives in input.

    Hence Guj

  4. Abhijeet
    guest
    Posted 4 months ago #

    I have never seen a format specifier like [^xyz]. Can someone explain it? Or give me a link?

  5. Dedicated Programmer
    Member
    Posted 4 months ago #

    @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.

  6. Abhijeet
    guest
    Posted 4 months ago #

    @Aashish

    Thanks man! Got it... Will try out a few programs to test this...


Reply

You must log in to post.

RSS feed for this topic