2
It was only supposed to work with lower-case letters and when it arrived at symbols it did not change, but they are being changed. What’s the problem?
#include <stdio.h>
int main()
{
char texto[100];
int i = 0,j = 0,con,tam;
printf("texto\n");
gets(texto);
fflush(stdin);
printf("constante\n");
scanf("%d",&con);
tam = strlen(texto);
char cesar[tam];
for(i = 0; i<tam; i++)
{
if(texto[i] >= 'a' || texto[i]<= 'z')
cesar[i] = ( (texto[i] - 97 + con)%26 + 97);
else
cesar[i] = texto[i];
printf("%c",cesar[i]);
}
}
You can use the function
toupper()
(prototype in<ctype.h>
) that, well configured, converts'ç'
in'Ç'
for example.– pmg
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero