C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Confusing error ?!?!

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Alf P. Steinbach
Guest





PostPosted: Sat Feb 28, 2004 8:58 pm    Post subject: Re: Confusing error ?!?! Reply with quote



* "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





PostPosted: Sat Feb 28, 2004 9:00 pm    Post subject: Confusing error ?!?! Reply with 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!??! 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





PostPosted: Sat Feb 28, 2004 9:12 pm    Post subject: socket programming Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.