I'm trying to make a cipher, and need to assign each letter its number value, how can I do this and make it printable? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I'm trying to make a cipher, and need to assign each letter its number value, how can I do this and make it printable?

This is what I have so far. include <iostream> using namespace std; int main() { char[1] = "abcdefghijklmnopqrstuvwxyz" ; return 0; }

4th Nov 2018, 11:35 PM
JDLives
2 Answers
0
Well, "char[1]" needs to become "char my_char[]" or similar. Judging by your code, you're not quite ready for anything complex. You need a solid grounding first.
4th Nov 2018, 11:59 PM
non
0
Make a char var like char a = 'a'; Then use int aa = static_cast<int>(a) and you will get the int value. Next make a key like adding 3 via a note in the code and use math. aa += 3. Then recast it. Might not be the best way now that I think about it but I typed this and it will give you something to play with. edit~ drawback is this will assume a consecutive order.
5th Nov 2018, 2:06 AM
James
James - avatar