Reading a full line of input

后端 未结 5 1847
广开言路
广开言路 2020-11-27 06:27

I\'m trying to store the input that user enters through console. so I need to include the \"enter\" and any white space.

But cin stops giving me input a

5条回答
  •  被撕碎了的回忆
    2020-11-27 07:04

    #include 
    #include 
    
    int main()
    {
    
        std::cout << "enter your name: ";
    
        std::string name;
    
        std::getline(std::cin, name);
    
        return 0;
    
    }
    

提交回复
热议问题