i was trying to solve MAYA
and found strange thing .
in my while loop getline does not ask for input in first iteration
please help..

  • created

    Jan '11
  • last reply

    Jan '11
  • 1

    reply

  • 181

    views

  • 2

    users

scanf doesn't remove any whitespace after the input from the input stream.

1   \n
2\n
3\n

The stream after scanf("%d",&n) is:

   \n
2\n
3\n

Just use getline once after the scanf.

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 13 5d

Want to read more? Browse other topics in C and C++ or view latest topics.