0

Hi there guys I need some help I am creating an inventory with loads of exception handlers, I got a problem with isalpha and isdigit because supposedly it will detect whether an input is a char or a digit... Ok I tested a simple program to show my problem. I only used if-else in this code for it to be less complicated. When I type in a letter or a number it just proceeds to press any key to continue... Can somebody figure out what's wrong with this?

#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
    int sample;
    
    cin>>sample;
    
    if(isalpha(sample))
    cout<<"sample is a char";
    else if(isdigit(sample))
    cout<<"sample is an integer";
    
    
    system("pause");
    return 0;
}

Edited by king03: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by MareoRaft
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.