0
I am trying to perform a URI exercise ,and in the 1 part it asks the following:
In the first step, only characters that are lower case letters and capital letters shall be moved 3 positions to the right according to table ASCII: letter 'a' should turn letter’d', letter 'y' should turn character '|' and so on
However he is also changing the ones that do not come out lowercase and uppercase ,I do not know why this is happening,I thank those who can help.
For example:
incoming texto #3
should get out wh{wr #3
,but it’s coming off wh{wr <
#include <stdio.h>
#include <string.h>
int main(){
char x[10],y[10];
int i,qnt;
fgets(x,sizeof(x),stdin);
qnt = strlen(x);
/******** 1 PASSADA ************/
for(i = 0;i<qnt;i++){
if (((x[i]>=65) && (x[i]<=90)) || ((x[i]>=97) && (x[i]<=122)) )
y[i]=x[i]+3;
printf("%d %d , %c \n",i,y[i],y[i]);
}
printf("tamanho da string %i \n",qnt);
printf("normal %d , %s\n",x,x);
printf("1 passada , %s \n",y);
printf("normal %d , %s\n",x,x);
for(i = 0;i<qnt;i++){
printf("%d %d , %c \n",i,x[i],x[i]);
}
}
Thanks for the quick reply!!. will make the changes, relative to the printf imprinting the string with %d I put only to see how it was /if it was possible. Thank you so much for the tips.
– Mark4