cant use isdigit

Hi all,

I declare a struct n an array of variable frm the struct. however I cant use isdigit to check whether hte use enters a no.

etc

struct Airline
{ char num[3]}

Airline Flight[3];

if(!isdigit(Flight[1].num){

cout << "Good";
}
I cant compile as I knw there muz b sumthing wrong with the way I use my isdigit.

Please advise
Are you including <cctype> ?
I have code in my program that uses isdigit, and it doesn't include cctype. so i don't think that's it.

What I am seeing however.. try this..
if(!isdigit(Flight[1].num[0]){

See if that helps.

Edit: Changed num[1] to num[0]. Remember these arrays are zero indexed.
Last edited on
Topic archived. No new replies allowed.