I'm doing an assignment for my C++ class where I am encrypting data from a file using the Caesar Cipher shift method where the character is shifted three places down the alphabet (without looping back around in the case of z). I'm taking that encryption, or decryption, and printing it to stdout and to a file called message.
I'm having issues with printing the decrypted message to stdout. For whatever reason, for messages of multiple lines, my code only displays the last decoded line to stdout, but the file I print the decoded message to has a full decoded message. Help??
Your program is working fine. Make sure you don't try to encrypt/decrypt "message.txt" -- otherwise you get read/write collisions.
C:\prog\caesar> copy con plain.txt
Hello world!
Time flies like an arrow,
Fruit flies like a banana.
^Z
1 file(s) copied.
C:\prog\caesar> a
Enter file name: plain.txt
[1]Encrypt
[2]Decrypt
1
Iuxlw#iolhv#olnh#d#edqdqd1
C:\prog\caesar> dir/b
a.cpp
a.exe
message.txt
plain.txt
C:\prog\caesar> copy message.txt cipher.txt
1 file(s) copied.
C:\prog\caesar> a
Enter file name: cipher.txt
[1]Encrypt
[2]Decrypt
2
Hello world!
Time flies like an arrow,
Fruit flies like a banana.
C:\prog\caesar> fc message.txt plain.txt
Comparing files message.txt and PLAIN.TXT
FC: no differences encountered
C:\prog\caesar>
Off topic and not a big deal, but this caught my eye:
12 13
//Data Abstraction:
This is actually just the opposite of abstraction. Abstraction is when you deal with concepts without worrying about the details. Here you are making the details concrete by defining the variables, so there is no abstraction here.