I want to convert a series of 32-bit integer values into a sequence of printable 8-bit character values. Mapping the 32-bit integers to printable 8-bit character values should result in a clear ASCII art image.
I can convert Integer to ASCII:
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
int main(){
char ascii;
int numeric;
cout << "Enter Number ";
cin >> numeric;
cout << "The ascii value of " << numeric << " is " << (char) numeric<<"\n\n"<<endl;
return 0;
}
Also I need to open the text file that my numbers are saved into:
You simply cout the entire line, instead, you should iterate over the file by the ::get() member function. You push this back into a string. Once you encounter a non-number character (In your case, a space), you need to int unit[x] = std::atoi(std::string). This converts the string to a number (integer). Once this is done, you can cast that integer to a char (You'll lose the last 24 bits tho, so having bits in any of the last 24 is useless, your range should be 0-255). Then you can std::cout that character.