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 7911793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:22:40+00:00 2026-06-03T13:22:40+00:00

Very simplified version of my code: #include <iostream> #include <string> using namespace std; int

  • 0

Very simplified version of my code:

#include <iostream>
#include <string>
using namespace std;

int main () {
string name;

cout << "Enter first and last name" << endl;
getline(cin, name);

return 0;
}

As you can see I want my user to type in their first and last name which will include white spaces. I would like to check it for numeric characters and if any are entered, throw up an error. An example input could be: “J0hn Sm1th” which would of course display an error.

I know I will have to use isAlpha() and I can get it to work if just numbers or if just letters are entered, but not when they are combined.

  • 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-06-03T13:22:41+00:00Added an answer on June 3, 2026 at 1:22 pm
    #include <cstddef>
    #include <string>
    
    bool check_name(const string& str)
    {
        for (std::size_t i = 0; i < str.size(); ++i)
            if (!((str[i]>='a' && str[i]<='z') ||
                  (str[i]>='A' && str[i]<='Z') ||
                   str[i]==' ' || str[i]=='-' ))
            return false;
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a (very) simplified version of my iPhone code : @interface x {
Very simple question, I made the following program : #include <stdlib.h> int main(int argc,
This is a very simplified version of some code I just ran into at
Here is very simplified version of code that i have: class PrintJob : IEntity
Please see the following example which is a very simplified version of my code:
Here's a simplified version of the code I'm using to perform simple HTTPS requests:
I'm using a MySQL database to store scores for my game. A very simplified
Here's a simplified version of my code: - (IBAction)convert:(id)sender { /* these two lines
Here is a simplified version of my Code: data Bookmark = Bookmark { url
The examples here show a very simplified version of a VIEW that I am

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.