Ok, i updated my code. no errors but warnings. and not getting the right result also.
Code:
#include <stdio.h>
#include <string.h>
char* shift(char *word, int key);
int main()
{
char word[3]="abc";
printf("\nThe key move is: %s\n", shift(word, 3));
return 0;
}
char *shift(char *word, int key)
{
int i,n;
int offset;
char decryptedLetter;
char decryptedword [3]= {};
for (i=0;i<strlen(word);i++)
{
offset = word[i]- 'A';
offset = (offset + key) % 26;
decryptedLetter = 'A' + offset;
for (n=0; n<=i; n++)
{
decryptedword[n]=decryptedLetter;
}
}
return decryptedword;
}
Warnings
text.c: In function âshiftâ:
text.c:19:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
text.c:29:5: warning: function returns address of local variable [enabled by default]
>a.out
The key move is: P~
·¿ân·àÄ·à
d ô¿·>
à
@ Km·Ã·ô¿·Lm·
ôabc
I have no idea what happend