The program initially asks the user to insert the secret sentence and the encryption code (an integer number in the range 1-100).
Then, the program calls a user-defined function void encrypter (char *, int) that accepts the string pointer and the encryption code. The encryption algorithm is based on the standard ASCII table and
encrypts the sentence character-by-character. The encrypted character is obtained from the original character plus the encryption code.
The function has to perform the encryption using pointers only; any operation n the string using array indexes is not allowed. Please consider that the string is always terminated with the NULL character; you can use this hint to loop over the string letters one-by-one using the NULL char as the exit condition. Moreover, please remember that a character can be treated as an unsigned integer. After the encryption function, the program displays the encrypted string on the screen. Immediately after, the decryption section is initiated asking the user to insert the number that breaks the
code. Then, the program calls a user-defined function void decrypter (char *, int) that takes the same string pointer and the decryption code and decrypts the string using the inverted algorithm.
The program and the user-defined functions have to be entirely based on string pointers and only one string declaration is allowed; the declaration of two strings (encrypted and decrypted) is not allowed. The integer code can be passed by-value; the string pointer is passed by-reference. Be sure that only the original numeric code is able to decrypt the original string. If not, the code will not be considered correct.
So far I have a program where I am attempting to use something like:
encrypt ( array_pointer, add_value ) {
int p_counter = array_pointer // This should become another pointer to the array
while ( *counter != NULL ) {
*p_counter = *p_counter + add_value;
p_counter ++; // This increases to the next byte in the string
}
}
... but can not get the program to run correctly using all the parameters defined in the above problem statment. if someone can help solve the porblem, or give me some advice/suggestions, i would appreciate it.