Hello. I'm writing codeing progam. It reads from file using fstream and then converts simbols to ascii, changes ascii, converts ascii to symbols and writes them to file. I tried to code .txt file with it. It worked perfect. But then i tried to convert .bmp file and then i decoded .bmp file and tried to watch pic i windows picture viewer showed me following error: "Drawing failed". I think i did something wrong. but i'm not sure... So i'm asking you is this possible to code and decode all files using fstream and converting symbols to ascii? Please answer me.
P.s sorry for my bad english. If you didn't understood me just ask.
fire_
0
Junior Poster in Training
Recommended Answers
Jump to Postcan you post the code you are using to decode the bmp?
Jump to Post.bmp files are binary files, not ascii text files. You have to open the file with ios::binary flag and then use ifstream's read() method to read the binary data. getline() will not work. And you will have to read the file into a character array, not a std::string object
All 7 Replies
chococrack
74
Junior Poster
fire_
0
Junior Poster in Training
fire_
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
fire_
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
fire_
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.