any other idea of validating user input except regular expressions

Discussion in 'C++' started by Oliver Bleckmann, Nov 30, 2006.

  1. how can i find out a string consists of letters/ numbers or other signs
    and especially how can i validate a date?
    Oliver Bleckmann, Nov 30, 2006
    #1
    1. Advertising

  2. Oliver Bleckmann

    BobR Guest

    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!

    --
    Bob R
    POVrookie
    BobR, Dec 1, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Leffer

    Validating paths using regular expressions

    Chris Leffer, Feb 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    296
    Chris Leffer
    Feb 21, 2005
  2. John Salerno
    Replies:
    20
    Views:
    808
    John Salerno
    Aug 11, 2006
  3. Replies:
    10
    Views:
    1,212
    Big K
    Feb 2, 2005
  4. Bernd Muent
    Replies:
    2
    Views:
    502
    Bernd Muent
    Feb 15, 2006
  5. Noman Shapiro
    Replies:
    0
    Views:
    216
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page