any other idea of validating user input except regular expressions

O

Oliver Bleckmann

how can i find out a string consists of letters/ numbers or other signs
and especially how can i validate a date?
 
B

BobR

Oliver Bleckmann wrote in message ...
how can i find out a string consists of letters/ numbers or other signs



#include <iostream>
#include <ostream>
#include <string>
#include <ccytpe>

int main(){
using std::cout; // for NG post
int Inum(0);
double Dnum(0);
std::string TestForNum("Hi 4 76.5num 42.7e-5");
cout<<"Test string = "<<TestForNum<<"."<<std::endl;
for(size_t i(0); i < TestForNum.size(); ++i){
cout<<"char at "<<i<<" is "<<TestForNum.at(i)<<", an ";
if( std::isdigit( TestForNum.at(i) ) ){
std::istringstream sis( TestForNum.substr( i ) );
sis >> Inum;
sis.clear();
sis.str( TestForNum.substr( i ) );
sis >> Dnum;
sis.clear();
cout<<"digit Inum="<<Inum
<<" Dnum="<<Dnum<<std::endl;
}
else{ cout<<"alpha"<<std::endl;}
}
return 0;
} // main()

and especially how can i validate a date?

Call her up and ask her if it's still on! Duh!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top