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
  • Needs to be written in C: Write a Caesar Cipher that decrypts a message from '...

    Needs to be written in C: Write a Caesar Cipher that decrypts a message from ' ' (Space, ASCII 32) to '~' (tilde, ASCII 126).

  • Can someone help me with a simple C programming problem? How do I make some code...

    Can someone help me with a simple C programming problem? How do I make some code like this into its own function? Currently it's pat of the main function, but I want to be able to call it. If you could help me with the prototype, function call, and definition, I'd really appreciate it. Thanks!    if(some_input=='r'){ someone = 0; } else if(some_input=='p'){ someone = 1; } else if(some_input=='s'){ someone = 2; } else if(some_input=='q' || some_input=='Q'){ break; // Breaks...

  • Can anyone help me make a simple maze using C++? Not an actual game just a...

    Can anyone help me make a simple maze using C++? Not an actual game just a maze. I'm learning the basics of C++ and I'm already stumped. I basically need C++ code to create a simple 32x32 ascii portrait of a maze. Please if anyone is a C++ I need some help thank you!

  • Write a MATLab code for a function m-file that that can take three inputs (f, y,...

    Write a MATLab code for a function m-file that that can take three inputs (f, y, t) and uses a while loop to examine f(x) for x = y, x = y+2t, x = y+4t, ... until a number is larger than the previous value and returns the x value for which this happens. Notes: Assume that f is decreasing at x=y but that there is a cutoff x=b > y after which f starts increasing. Assume the input for...

  • Can someone help me write a retirement calculator program in c code. I want to write...

    Can someone help me write a retirement calculator program in c code. I want to write a program that the user can enter their age, amount they wish to save each month, the interest rate, and the age they wish to retire. I would like to use a switch loop, if else loop or do while loop. the output should show them how much they should have in a retirement savings account at the age they wish to retire at....

  • Can someone help me write my code/set up LabView using the DAQ for 7 thermocouples and...

    Can someone help me write my code/set up LabView using the DAQ for 7 thermocouples and one pressure transducer? step by step if possible, thank you! j type thermocouples

  • C++ Can someone please help me with this problem- commenting each line of code so I...

    C++ Can someone please help me with this problem- commenting each line of code so I can understand how to solve this problem using the C++ programming language? I really need help understanding how to create a file for the program to read. Do I create the file in Visual basic or create a text file? I have the code, just need to know how to create the file for it to read. #include<fstream> #include<iostream> using namespace std; int main()...

  • Write a C++ code to make a simple program that imports the input file in and...

    Write a C++ code to make a simple program that imports the input file in and gets the results as specified Please follow the instructions and paste the code below as the answer with a screenshot of the output to prove it worked. Input file -> https://www.dropbox.com/s/444jofkchu6ylwr/names.txt?dl=0 Scoring Names You will be using the provided names.txt file, text file containing over five-thousand first names, and you will calculate a score for each name. Begin by reading the names from the...

  • Write a C++ program that reads text from a file and encrypts the file by adding...

    Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. 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...

  • C PROGRAMMING -- Please use simple code QUESTION: - Write a charQueue header file containing all...

    C PROGRAMMING -- Please use simple code QUESTION: - Write a charQueue header file containing all the function headers of following functions: 1- initiateQueue—to initialize a queue 2- enqueue—to add a node at the rear end of the queue 3- dequeue—to remove a node from the front of the queue 4- printQueue—print a queue and an implementation file implementing these functions for a Queue of chars. Inside your main method, which should be part of your tester file, read a...

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