i have an assignment at school where
we have to get a string entered by a user
and then the program is supposed to encrypt it
by adding 13 to A-M and -13 from M-Z so that if
i inputted A B C i would get N O P. Basically its adding 13 to
the value that the user entered and we also have to
convert all the lower case characters to upper case using
the "toupper" function.i have already tried it and i have two strings
. i copied string1 into string2 and i tried to do a for loop
to loop through all the characters and i m lost. I tried asking the teacher
but i dont understand how to do it too. i asked the TA but he wasnt much help too.
Can someone at least give me a few pointers. i am not asking for the answers right away
just a little help or pointer that i can go on or point me in the right
direction.
thank you in advance.
#include <stdio.h>
17 #include<strings.h>
18
19 #define SIZE 100
20
21 void input(char string1[SIZE]); //prototype function to get user data
22 void rotate(char string1[SIZE], char string2[SIZE]); //prototype function to encrypt sentence
23 void print(char string1[SIZE], char string2[SIZE]); //prototype function to print sentence
24
25
26 int main()
27 {
28 char string1[SIZE]; //declaring the first string
29 char string2[SIZE]; //declaring the second string to be encrypted
30 input(string1); //get user sentence
31 rotate(string1, string2); //rotate user sentence
32 print(string1, string2); //print out the two strings
33
34 return 0;
35 }
36
37
38 //get a sentence to be incrypted from the user
39 void input(char string1[SIZE])
40 {
41 printf("Please enter a sentence to be encrypted \n");
42 fgets(string1,SIZE,stdin);
43 }
44
45 //rotate the sentence that the user inputted
46 void rotate(char string1[SIZE], char string2[SIZE])
47 {
48 char i;
49 char temp[SIZE];
50 char temp[SIZE];
51 strcpy(string2, string1);
52 for(i=0;i<strlen(string2);i++)
53 new[i]=temp[i]+13;
54 if(
{
56 printf
57
58
59
60 }
61
62 //print out the rotated and original sentence
63 void print(char string1[SIZE], char string2[SIZE])
64 {
65 puts("original sentence");
66 printf(" %s \n", string1);
67 puts("encrypted sentence");
68 printf(" %s \n", string2);
69 }