Y resulta eferion, que logré hacer las validaciones, pongo el código:
Código C++:
Ver original#include <ctime>
#include <ctype.h>
#include <cstring>
#ifndef UTIL_H
#define UTIL_H
using namespace std;
bool checkInt(string s){
int cont =0;
for(int i=0; i < s.size(); i++){
if(s[i] >= 90 and s[i]<= 122) {
cont++;
}
}
return !s.empty() and cont == 0;
}
bool checkStr(string s){
int cont =0;
for(int i=0; i < s.size(); i++){
if(s[i] >= 48 and s[i]<= 57) {
cont++;
}
}
return !s.empty() and cont == 0;
}
void pause(int dur) {
int temp
= time(NULL
) + dur
; while(temp
> time(NULL
)); }
string passUpper(string s){
for(int i=0; i < s.size(); i++){
}
return s;
}
string addString(string type){
int intento = 1;
string nom = "";
while(!checkStr(nom)){
cout << "\n intento nro "<< intento << " Ingrese " << type <<": ";
cin >> nom;
intento++;
}
return passUpper(nom);
}
int addInt(string type){
int intento = 1;
string numero;
while(!checkInt(numero)){
cout << "\n intento nro "<< intento << " Ingrese " << type <<": ";
cin >> numero;
intento++;
}
return std::stoi(numero);
}
#endif /* UTIL_H */
Mil gracias tanto a tí como a Instru.
Saludos.