and so your favourite noob is back and asking for help yet one more time.
So i gotta write a programm that gets a string from a user and modifys it like:
First calls a func that does the following:
turns all 'e' & 'y' into 'i'.
Also turns all 'u' to 'a'. so far so good, i've done it and works....(y this was easy i know)
BUT ( cause there is always a but to be afraid of...)
the 2nd part of it is to call a 2nd func that will delete every double character found, like if a character is appearing two times in a row like:
If there are 2 l's together like "ll" it will delete one of them.If there are 2 t's like "tt" it will delete one of them,and so on.
Programms example:
Give string: (user types---->)hello it is a pitty to hear that
(programm output------>) hilo it is a piti to hiar that.
So far i got this code on:
Code:
#include <stdio.h>
#include <string>
char ustr[250],nstr[250],fstr[250];/* USERstring,NEWstring,FINALstring*/
int i;
char simplifychar();
char simplifychar()
{
if ((ustr[i]=='i') || (ustr[i]=='e') || (ustr[i]=='y'))
{ return 'i';
}
else
{
if (ustr[i]=='u')
{
return 'a';
}
else
return ustr[i];
}
}
char deletedouble();
char deletedouble()
{
if (nstr[i]!=nstr[i+1])/* checks if the next character is the same as the one curently "scanning"*/
{
return nstr[i];
}
}
int main()
{printf("Give a string:");
gets(ustr);
for (i=0;i<250;i++)
{
nstr[i]=simplifychar();
}
for (i=0;i<250;i++)
{
fstr[i]=deletedouble();
}
printf("New string :");
puts(fstr);
}
but when i run it the deletedouble does not do what i want it to do, and i cant find my error :S
Thanks for your time
Cursy