Hi! :)

I've been given a task in which I have to code a C++ program where an encryption key string with a length of 26 small alphabet is asked, then the user must input a word to encrypt and then it shows the encrypted word. If the encryption key has not all the characters, then the program shows the ones that are missing.

I've trying to study this thing a lot in google and c++ books but I'm a beginner, just learned how to use loops and so. i dont know at all where to start. Should I use just strings, or arrays or what?

If theres some pointers you could give me, i would be very happy ! :)

It depends on what, if you want to manually write a program to flip the letter per plase each time (ex time miet, qwer ewrq) than arrears are where to go, also if you want to use it with q filename use arrays, strings would be harder to work with but would be easier to send though a XOR gate... I would say that in your case you should start first with a number encryption program than move on, it took me three months to even be able to use fstream without directly looking at a guide on paper, and just recently learned binary mode, don't rush yourself, I remember crying and cursing at my compiler and IDE several times in my programing career.

Welcome mikkey91!

Strings and arrays will both work. Learning how to decide up-front which way to go is something you learn only with plenty of experience. For now, pick whatever you're comfortable with, and figure out how to implement what you need. If you have time, go back and implement it a different way also, just for the experience.

This encryption topic shows up in the DaniWeb forums every couple of months, so it's clearly a favorite assignment. If you go back through this C++ forum, you'll definitely find related threads. Especially if you mention Vigenere, like I just did, you'll probably find relevant threads listed on the right-hand side of the web-page. ;)

As far as how to start, just think through what the program has to do, and in what order, then add details a little at a time. Start with asking the user for the encryption key, and printing that back out. Then use it to encrypt a hard-coded string and print out the original and encrypted strings to verify that it has done the encryption correctly. And so on. In no time you'll have the entire assignment completed. Good luck and post back (including your code so far) if you have more questions!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.