Question:
Write a program that reads the integers in the file “flints.txt” (the integers stored in the file are the ASCII code for characters), converts each integer to a char, and outputs each character a text file. There is no need for an array. ASCII table can be found here.
Note that given an int value called number (which stores the ASCII code for a character), either of the following statements can convert number to the corresponding char.
char theChar = static_cast<char>(number);
char theChar = (char) number;
My Program:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream myfile ("code");
string line;
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line << '\n';
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
If you could explain to me what to do next and why, that would be great. :)