Horje
getline int Code Example
getline int
#include<iostream>
#include<sstream>

int main(){
    std::stringstream ss;

    ss.clear();
    ss.str("");

    std::string input = "";

    int n;

    while (true){
        if (!getline(cin, input))
            return -1;

        ss.str(input);

        if (ss >> n)
            break;

        std::cout << "Invalid number, please try again" << std::endl;

        ss.clear();
        ss.str("");
        input.clear();
}




Cpp

Related
define a type in c++ Code Example define a type in c++ Code Example
input in c++ Code Example input in c++ Code Example
how to get the first element of a map in c++ Code Example how to get the first element of a map in c++ Code Example
why is my unity crashing Code Example why is my unity crashing Code Example
PascalName seperate strings Code Example PascalName seperate strings Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8