The program is meant to read a .txt file a line at a time using getline.
Encrypt each character adding an encryption factor to the ASCII value and write the string to a second file.
The encoded file should have the same structure as the original file (if original file has 26 characters on the first line the encrypted will have 26 characters on the first line).
The encryption factor adds the number of the line to the ASCII value of each character, up to the 5th line then starts back at 1. (n-1)%5+1
I do not write in C++ well yet and figured I would start with adding a constant number first.
I could also imagine that the std namespace is pretty expansive so would you recommend using it while still learning all the symbols in the library?
I guess what I'm trying to figure out is, is it okay to use starting out? Or should I absolutely avoid it at all costs so as to not develop any bad habits?
In this instance, I don't like overloading operator+. + usually means addition or concatenation. I used % above which is not ideal but IMO is better than + in this context.
Well, my logic is that:
'c' + n will work for a single char;
A string is an array of chars
string + n is just an array operation (I'm used to languages doing precisely that).
But
%
is a modular division, which, if anything here, means "break up".
The closest operator here would probably be >>, but that would play havoc with input/output.
You could always use a function directly, and call it "shift".
Why overload the operator at all? It could clash with somebody else's overload, couldn't it? Wouldn't it be better to just use a regular function?
(I'm asking.. not suggesting)