I am trying to make a program that encodes and decodes strings that are given by the user by the cesar method, using switch-case to select what should be done, however when trying to read a string inside the case of the case this occurs) the program ignores the scanf and goes straight to the next line. I already tried everything I knew and nothing worked, any help would be welcome.
The text and message strings are both size 50, alf is a string that contains the alphabet, key is an int that is the number of houses that are advanced in the given message.
My code looks like this: / p>
case 1:
printf("Digite sua Mensagem\n");
scanf("%[^\n]s",texto);
strcpy(mensagem,texto);
printf("Digite a Chave de Codificação\n");
scanf("%d",&chave);
for(i=0;i<strlen(texto);i++) //loop p/ cada caractere da mensagem inicial
for(j=0;j<strlen(alf);j++){ //loop p/ cada caractere da mensagem inicial
if(texto[i]==alf[j]){
mensagem[i]=alf[j+chave];
break;
}else if(texto[i]==toupper(alf[j])){
mensagem[i]=toupper(alf[j+chave]);
break;
}else if(isspace(texto[i]))
break;
}
system("cls");
printf("A Mensagem Encriptada É:\n");
printf("%s\n",mensagem);
system("pause");
break;