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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:52:17+00:00 2026-06-14T13:52:17+00:00

I posted an earlier question asking for help with using a validation script in

  • 0

I posted an earlier question asking for help with using a validation script in my code. After a very helpful answer I was able to sort of figure out how I needed to proceed. Well, I’ve hit a big obstacle;

#include <iostream>
#include <sstream>
#include <string>
#include <ctype.h>

using namespace std;

int main()
{
        unsigned __int64 input = 0;
        int n, i;
        char str[]="c3po...";
        i=1;
        n=0;


        for (cout << "Input a number" << endl; cin >> input; cin.ignore(numeric_limits<int>::max(), '\n'))
    {
        cout << "We're parsing your input '" << input << "'\n";

     if (input % 2 == 0) 
        {
            cout << "Even!" << endl;
        }

    else if (input % 2 == 1)
        {
            cout << "Odd" << endl;
            cout << "Lets make it even shall we? " << "Your new number is... " << input + 1 << endl;
        }
    else (isalnum(str[i]));i++;
        { 
        cout << "We could not parse '" << input << "' as a number.\n";
        }    
    }
    system ("pause");
    return 0;
}

As you can see from my code, the validation script is well, sort of working. I have some bugs I wish to iron out.

1- When I input a number, it runs though the code as it should but it also displays

Could not parse 'inputted number' as a number

obviously when a number is inputted you don’t want this to happen!

2- For the error message, it is showing the inputted number as [0]. Is this to do with using an integer? How can this be fixed?

Thanks!

  • 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-14T13:52:18+00:00Added an answer on June 14, 2026 at 1:52 pm

    your problem is quite simple, you have small mistake on this line

    else (isalnum(str[i]));
    

    Your else statement ends at the semicolon and does actually nothing. Following statements will be executed every time.

    i++;
        { 
        cout << "We could not parse '" << input << "' as a number.\n";
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I posted this question earlier about dynamically compiling code in C#, and the answer
I posted a question similar to this earlier, however, after thinking about it and
I posted a similar question earlier and received some good suggestions. After further investigation,
I had posted a question earlier attempting to find an error in my code,
I posted a question earlier about stopping all sounds in a swf. Now, to
I had posted one question earlier jQuery inconsistency in setting readonly attribute in IE-8
This is a related question to one I posted earlier... I'm trying to sum
This is a follow-up to an earlier question I posted on EF4 entity keys
This is a related question to one I posted earlier today, I was initially
So I posted an earlier question here: upload And I tried the solutions but

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.