Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3353490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:09:27+00:00 2026-05-18T02:09:27+00:00

I just started c++ today. I am doing some simple registration program. I want

  • 0

I just started c++ today. I am doing some simple registration program. I want to validate the input. I got stuck when validate fullname and birth_date. Here is my requirements:

  • Fullname: I just want to check if its empty and no punctuation
  • date_birth: i know this is abit tricky. But if I could validate if the input is valid like: month(1-12), date(1-30) and year (not more than current year) should be enough.

Any quick way to do this?

EDIT:

I tried googled string validation, i am still getting lots of errors. Here is my current code:

string fullname;
do{
    cout << endl << "Please enter your fullname";
    cin >> fullname;
} while(!ispunct(fullname));

My error message is:

XXXX: no matching function for call to `ispunct(std::string&)' 

I already include the library, is this a correct way to check string input. How do you usually do the validation?

EDIT 2:

bool valid;
string fullname;
do{
    valid = true;
    cout << endl << "Please enter your fullname";
    cin >> fullname;
    string::iterator it;

      for ( it=fullname.begin() ; it < fullname.end(); it++ )
          if(ispunct(*it)){
              valid = false;
          }
} while(!ispunct(fullname));

Its weird, I entered: “!!!”, it still by pass. Something is wrong in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:09:28+00:00Added an answer on May 18, 2026 at 2:09 am

    Well, I’ll try to steer you in the right direction. Firstly, in order to validate the string, you’ll need to iterate over it character by character. You can do this using iterators and a for loop. The string class has a begin() and end() method, which you can use to loop over the whole string and examine each character.

    Once you’re looping over the string, all you need to do is write code to validate it based on your requirements. To make sure there’s no punctuation characters, you can use the std::ispunct function, which will tell you whether or not a character is a punctuation character. If you find any punctuation characters, simply consider it an error.

    Your first requirement, checking whether the string is empty, is trivial. The string class has an empty() method which returns true if the string is empty.

    Validating the birthday is more tricky. This is the sort of thing regular expressions were made for. Unfortunately, C++ has no built-in support for regular expressions (at least not until the next version of the standard). If you’re interested, Boost has a good regular expression library in the meantime.

    Otherwise, you’ll need to loop over the string and validate each character. Make sure the string starts with characters that form a word corresponding to a month name, then make sure a parenthesis falls after that, etc. You’ll need to decide how to handle white spaces in between characters. This will be tricky, but it’s a good practice exercise to become familiar with C++.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.