Question

can someone help write a simple c++ code that inputs a file and decrypts it using...

can someone help write a simple c++ code that inputs a file and decrypts it using ascii code -4.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main() {
    string fileName;
    cout << "Enter file name: ";
    cin >> fileName;
    ifstream in(fileName.c_str());
    if(in.is_open()) {
        string line, result;
        while (getline(in, line)) {
            for (int i = 0; i < line.size(); ++i) {
                result += (char)(line[i]-4);
            }
            cout << result << endl;
        }
        in.close();
    } else {
        cout << fileName << " does not exists!" << endl;
    }
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
can someone help write a simple c++ code that inputs a file and decrypts it using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT