Write c code to open a document with the name hellotxt


Assignment

Part A

Complete the following questions:

Write C++ code to open a document with the name Hello.txt, place the message "Hello, World!" in the document, and exit the document. Re open the file you closed, and read the message into a string variable. Exit out of the file.

/* 1. Write C++ code to open a document with the name Hello.txt,

place the message "Hello, World!" in the document, and exit the document.

Re open the file you closed, and read the message into a string variable.

Exit out of the file.*/

When do you open the file as an ifstream, as an ofstream, or as an fstream? Could you simply open all files as an fstream?

Why is the ifstream parameter of the read_data procedure in the previous question a reference parameter and not a value parameter?

What is the difference between a text file, and a binary file?

Part B

Random monoalphabet cipher.

The caeser cipher, which shifts all letters by a certain amount, is easy to decipher. Try this, instead of numbers use letters. Consider this, the word is FEATHER. Remove duplicate letters, making FEATHR, and append the rest of the letters of the alphabet in reverse order.

Now encrypt the letters as follows:

Now, write a program that encrypts or decrypts a file using this cipher.

Include the .cpp file in addition to the responses above.

For example,

crypt -d -kFEATHER encrypt.txt output.txt

decrypts a file using the keyword FEATHER. You must always supply a keyword.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write c code to open a document with the name hellotxt
Reference No:- TGS01724779

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)