Apr 2, 2009 at 2:21pm UTC
wads the problem with tis...
int digit=0,consonant=0,space=0,vowel=0,i,c;
char text[256];
cout<<"Input a line of text terminated with the @ character -> ";
cout<<endl;
cin.getline(text,256,'\n');
for (i=0;i<=256;i++)
{
c=text[i];
if (isdigit(c))
{
digit++;
}
}
Apr 2, 2009 at 2:38pm UTC
Your for loop walks beyond the end of the string.
EDIT: not only beyond the end of the string the user typed, which can be less than 255 characters, but also beyond the end of the array.
Last edited on Apr 2, 2009 at 2:39pm UTC
Apr 2, 2009 at 2:40pm UTC
That program is counting the number characters in the string. If you want to make it counting the spaces in it, you should just change the if
condition