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);
Yeah thank you i got the code working but it is not outputting anything so i am just wondering if i saved the file that i am using wrong. So is there a special process of saving these file???
Also post your revised code so the changes can be seen not guessed at.
And,
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
# include <fstream>
int main() {
std::ifstream input("code"); // open the file named codefor (int ccode; input >> ccode; ) // while we successfully read integers from the file
std::cout << static_cast<char>(ccode); // convert them to chars, send to standard output
}