Question

I have coded the huffman tree without problems but now I look to add the Pseudo EOF in the file and tree so I know when to stop reading from the file.

I fully grasp the concept of the Pseudo EOF. I also understand that there are no characters with an ASCII value of > 255.

What I don't fully understand is the adding of that character to the input file. If it has to be a non-ASCII character (because they can be in the file) then what character am I supposed to add to indicate EOF?

Était-ce utile?

La solution

I'm not sure you do really understand what a "pseudo EOF" is all about.

First, as per the comments, there is no ASCII char greater than 256. Nor is one needed.

What you are being asked to do is to simulate this in code. Say you have a function that reads a character:

int getchar(fhandle);

This function will return values from 0 to 255 to represent ASCII characters. It can also return a special value such as -1 to indicate end of file. This special value is the "pseudo EOF".

This character is not in the file. It is returned by the function when there are no more characters in the file.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top