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;
    cout<<"sample is a char";
    else if(isdigit(sample))
    cout<<"sample is an integer";
    return 0;

Recommended Answers

Change int sample to char sample .

Jump to Post

All 2 Replies

Change int sample to char sample .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.