#include <iostream> // libraries
#include <iomanip>
#include <string>
usingnamespace std;
int main()
{
char str[80];
int i;
cout << "enter a string . Remeber to hit space at the end"<<endl; // prompting user
cin.getline(str,80); // geting line
cout<<endl;
i =0;
while (str[i]!='\0')
{
int cnt = 0; // number counter
int counter=0; // char counter
//loop until I get to the space character
while(str[i] != ' '){
cout << str[i];
if (str[i]>='0' & str[i] <='9'){
cnt+=1;
}
counter+=1; i+=1;
}
if(cnt == counter)
{
cout << " is a nunber" << endl;
}
else
{
cout << " not a number" << endl;
}
i++;
//if number counter == char counter then all my charcters are numbers
//if not then its not a number
}
}
enter a string . Remeber to hit space at the end
324dsf 323 dsaf 31
324dsf not a number
323 is a nunber
dsaf not a number
31 is a nunber
Press any key to continue . . .