Question
I need help with my code. Below is the assignment and I have attached pictures of my code. I already added plain.txt and coded.txt to
I need help with my code. Below is the assignment and I have attached pictures of my code. I already added plain.txt and coded.txt to the program. Its output seems to be right. The problem I have is that instead of printing out (in the output) the coded formart it over does it. I am suppose to get the same amount of characters and lines as the plain.txt with the coded.txt output. Instead of only 8 lines I get 154 of encrypted code. Please help.
I already wrote word for word and line for line by hand so there wouldnt be any extra space in the .txt format.
Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character.
Your program should:
1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8).
2. Change each character of the string by adding 6 to it.
3. Write the encoded string to a second file, such as coded.txt
4. The encoded file should have the same structure as the original file, if the second line of the original file has 24 characters (including spaces) then there should be 24 characters on the second line of the encoded file (spaces will now look like '&').
Hints: 1. In Visual Studio Express, put your plain.txt file in the project directory. The same folder that your C++ source (.cpp) file is in. 2. One of the challenges is to keep reading lines from the plain.txt file until the end. Sections 12.4 and 12.5 describe how you can do that.
plain.txt
This is a sample input file for COSC 1436 assignment #10. Your program should encode this file by adding six to the ASCII value of each character in it. In your encoded file the first character should be 'Z'. The last character of the first line should be '
coded.txt
Znoy&oy&g&ygsvrk&otv{z&lork&lux&IUYI&7:9&rotky&ul&zk~z&p{yz&roqk&znoy&utk2 h{z&}orr&hk&{txkgjghrk4&Znk&rgyz&ingxgizkx&ul&znk&rgyz&rotk&}orr hk&g&-:-4
aincludec iostream # includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started