 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alf P. Steinbach Guest
|
Posted: Sat Feb 28, 2004 8:58 pm Post subject: Re: Confusing error ?!?! |
|
|
* "dwaonng" <dwaonng1234 (AT) yahoo (DOT) com> schriebt:
| Quote: |
im working on a prgm to do LZW compression
In a file I stored a character with the code: 26(binary:00011010)
when I try to retreive the code from the file I get the int value -1
and(binary:11111111111111111111111111111111), why is that!??!
|
That's a feature of the compiler, library and/or operating system you're
using (for example, in MS-DOS a Ctrl Z marks end-of-file for a text file),
which standard C++ very unfortunately not only allows but encourages --
give me a whip and the committee members, and I'll whip 'em for you, very
enthusiastically.
To avoid this problem use binary file mode, not text mode.
| Quote: | Is it possible to get the character code 26 back from the file it
was stored in?
|
Yes.
|
|
| Back to top |
|
 |
dwaonng Guest
|
Posted: Sat Feb 28, 2004 9:00 pm Post subject: Confusing error ?!?! |
|
|
im working on a prgm to do LZW compression
In a file I stored a character with the code: 26(binary:00011010) when I try to retreive the code from the file I get the int value -1 and(binary:11111111111111111111111111111111), why is that!??! Is it possible to get the character code 26 back from the file it was stored in?
I know the character value is 26 definitely but using getc() doesnt give me the correct value back. Also that the character code 26 represents SUB (no idea).
#include <iostream.h>
#include <stdio.h>
void main()
{
FILE *input=fopen("1.txt","r");
cout << "n(getc(input): " << (int) getc(input);
fclose(input);
}
|
|
| Back to top |
|
 |
Poiquiop Guest
|
Posted: Sat Feb 28, 2004 9:12 pm Post subject: socket programming |
|
|
Hi. I was wondering if there were any good tutorials related to socket
programming, and handling different protocols, etc.
Thanks,
J.L.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|