so basically I need to create a encryption function using rot . The function shold not contain the string to be encrypted and should not contain a decryption function
it starts like this
#include "encrypt.h"
std::string encrypt (std::string text, int rot) {
and ends like this
return NULL;
}
I thoug in setting a int and putting ita a value and then put the rot or in putting a cin and then rot cout but it seem I cant get to a correct anwser and to write the code correctly.
you are right NwN the only information I have is this include
"encrypt.h"
string encrypt (string text, int rot) {
}
The function begins like that and I need to create a function that can encrypt different strings that I dont knoe and they should only encrypt the letter so the numbers,spaces,etc shoul remain the same.
The key thing to remember here is that every character in C++ is internally represented as a number, and can thus be treated as such. For an overview, please see this page: http://www.cplusplus.com/doc/ascii/
Now, the string will be passed into the function, you will have to look at every character, so you will need some sort of loop to access each character.
For every character, you check whether the character is a letter. If it is, you can just increase it by rot, the other function parameter.
Some hints:
- Individual characters of a string can be accessed as such: string[n], where n is a number representing the position of a letter in the string.
- http://www.cplusplus.com/reference/cctype/isalpha/
Please do let us know if you require any further help.
The function shold not contain the string to be encrypted
I thoug in setting a int and putting ita a value and then put the rot or in putting a cin and then rot cout but it seem I cant get to a correct anwser and to write the code correctly.
no offense, but i don't understand what do you mean... seriously...