my name n times ?? what is the solution sir??
again. this reads a number into n and the rest of that line into str and prints that n times. How does your input look like? And what do you expect? The code does what it is supposed to do. I assume your input is this 123 Name So the underlying stream will contain 123\nName. You start by reading the number (123), so you are left with \nName in the buffer. Calling getline() on that stream will return an empty string since there are 0 characters before the next new line character. You could call ingore before getline to get rid of that new line character, e.g. std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); Otherwise try entering 123Hello and see what happens.
thanks for your response sir... now i got this ..
Обсуждают сегодня