This is simple code, but I can not understand the strange event. The code:
void Crittografia::CifraTesto(char text[]){
int i;
for (i=0;i<strlen(text);i++){
text[i]=text[i] + key;
if(text[i] > 'z'){
text[i]=text[i] - 26;
}
}
}
The function gets the line entered here:
It works .
In this case, it works with the key 5. 'y', changed to 'd' correctly.
But in this case: Does not work .
With the key from 7, it changes "y" to "Ç" instead of the correct "f", therefore, apparently, it does not execute the line: "text [i] = text [i] - 26;"
source
share