Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- using namespace std;
- /*Validar entrada unicamente de tipo int*/
- int pedirInt(string);
- int main()
- {
- int numero;
- numero = pedirInt("Ingrese Numero: ");
- cout << endl << "Su Numero: " << numero << endl;
- return 0;
- }
- int pedirInt(string texto){
- int valorInt;
- bool terminado = false;
- do{
- cout << texto;
- string linea;
- getline(cin, linea);
- stringstream ss(linea);
- if (ss >> valorInt)
- terminado = true;
- }while(terminado == false);
- return valorInt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement