I'm creating a simple cipher and i got stuck on a weird problem with which i believe is with my IF's.
char name[25];
char cipher[25];
gets(name);
int i;
for( i = 0; i <= 25; i++ )
{
cipher[i] = name[i];
if( name[i] = 'g' ) {
cipher[i] = 'a';
};
cout << cipher[i];
};
cipher[i] = name[i];
is there to copy one array to another, so then only one array gets changed. It works. And rest of the program, in my understanding, works like this: if there is a letter g
in name[0]
, make it a letter a
in cipher[0]
and if there isn't, just skip, repeat 25 times. But the results are so random to me i don't understand what's going on at all...