Code:#include <stdio.h> #include <string.h> int main (int argc, char *argv[]) { int i=0; int input=0; char str1[i]; char str2[i]; int n; printf("Please enter shift [0--25]: %d %c \n", input, str1[i]); //read a number between 0 and 25 and then read a list of characters n=scanf("%c", &str1[i]); i=0; while (str1[i] != '\0') { str2[i] = str1[i]; i=i+input; //This will shift the string of characters by the read number's value } str2[i] = '\0'; printf("%c", str2[i]); return n; }
The above is the program I wrote. The output should be the following for example:
Please enter shift [0--25]: 5
abcd (what the user types in)
fghi (what comes out, a + 5 = f, b + 5 = g, etc)
ctrl d
Thank you for any help



LinkBack URL
About LinkBacks


