#include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
int x = 0;
char letter[256];
cout<<"Push a key: ";
cin>>letter;
if (atoi(letter)==x)
{
cout<<"I push a letter"<<endl;
}
else
{
cout<<"I push a number"<<endl;
}
cout<<endl;
}
and all I want is that this code to recognize 0 as number (integer), not as a letter (I need to separate all the numbers from all the letters).Any idea is much appreciated.Thanks!
cout<<"Push a key: ";
cin>>ch;
if (ch=='0'||ch=='1'||ch=='2'||ch=='3'||ch=='4'||ch=='5'||ch=='6'||ch=='7'||ch=='8'||ch=='9')
{
cout<<ch<<endl;
cout<<"I push a number"<<endl;
}
else
{
cout<<ch<<endl;
cout<<"I push a letter"<<endl;
}