I'm a c++ beginner.
I have a classwork which I have tried to complete for a few days now and I'm still confused.
I have a file called Data.txt .
It contains
757935403 544999979 175906848 538976380
757795452 170601773
What I have to do is take those 32 bit integer values and covert them into a 4 byte char. Which in the console will display an ASCII art image.
They are asking me to also learn how to split an 32 bit integer into 4 ASCII char.
This is the art image:
+---+
| |
| |
+---+
So I tried converting it to Hexadecimal first then to convert them into ASCII.
I will try show you how I began my code but change it if you want to, because im just 4 weeks into learning c++.
Awesome thanks for refining the code. However the Output is not synchronized according required one, I will try something from there and update it. Also the
One way to get a byte from an int is to use bitwise operations, a combination of shifting and masking will do the job. Rather than write the whole program, here are some ideas/example to start off with. I've not given a lot of explanation, but the first part is an example, then the second part shows one of the samples from the original question.
Hey guys I have completed the code that required to display the integers from the file into the console window as ASCII characters.
At the moment I am still currently in the works of modifying the code to put in other lines to replace the code in void display() because my syllabus never covered it. Well its part of my brain forcing me to try complete it in my own way. But I learned a few methods just from this on how to display this output. Thanks again guys.
Specifically thanks [Thomas1965 and Chervil].
My output is in a printscreen link, not sure how to display that here.
*This output is used to display another input file which contains shit tons of integers*