Hi.
I have to write a program that will return the amount of all the vowels on a string.. I already did it, but it freezez during the execution :sad: . Any suggetions are welcome.
ps.I must say that I am a begginer on this... :o
Here is the code:
#include <iostream.h>
#include <string.h>
#include <iomanip.h>
void cuenta_vocales(char palabra[])
{
char vocales[6],
*pch;
int count=0;
vocales[0]= 'a';
vocales[1]= 'e';
vocales[2]= 'i';
vocales[3]= 'o';
vocales[4]= 'u';
for (int i=0; i<=4; i++)
{
strcpy (pch,palabra);
while( pch != NULL )
{
pch=strchr(pch, vocales[i]);
if( pch!=NULL )
{
count++;
}
}
}
cout<<"Cantidad de vocales en "<<palabra<<": "<<count<<endl;
}
void main()
{
char palabra[30];
cout<<"Entre la palabra que desea evaluar:\n";
cin>>palabra;
cuenta_vocales(palabra);
}
<< moderator edit: added [code][/code] tags >>