Getline keeps on getting newline character. How can I avoid this?

前端 未结 6 1702
离开以前
离开以前 2020-12-14 23:56

Basically I first takes an integer as input and then test case follows. My each test case is an string. I am suppose to print the string back if the starting patten of strin

6条回答
  •  攒了一身酷
    2020-12-15 00:36

    cin.ignore() worked for me.

    void House::provideRoomName()
    {
        int noOfRooms;
    
        cout<<"Enter the number of Rooms::";
        cin>>noOfRooms;
        cout<

提交回复
热议问题