I nead to load a file ficture.txt,... run huffman and save it to a file so far I only have it working for textfiles. Can any one please tell me what function to use to load/save any data and convert it to bits/ from bits
Asked
Active
Viewed 91 times
1 Answers
0
One byte at a time is the smallest amount one can read from a file.
So, you can read a byte at the time and store it an a char
variable.
Then, you can extract the bits
of the byte
, by using bitwise operators <<
and >>
.
[EDIT]
Answering to the comment:
Read byte by byte from file in C++.
Also, you might want to take a look at the ifstream reference.
-
but what function do i use for reading a file ant then converting it ? – Shawn May 10 '14 at 09:40
-
@Shawn I did edit my answer, but please search a bit before asking. :) – gsamaras May 10 '14 at 09:45
-
@Shawn, I saw that your question is downvoted. The reason might be that you didn't show some effort (usually the OP makes an attempt, posts his code and asks why this doesn't work). Also, if you are OK with my answer, let me know, so that I can log off without worrying about it. – gsamaras May 10 '14 at 09:53
-
your awnser is amazing. I was searching for the awser myself but i didnt found anything usefful so i didnt wrote it down here. Thank you so much. – Shawn May 10 '14 at 09:58