Confusing error ?!?!

From: dwaonng (dwaonng1234_at_yahoo.com)
Date: 02/28/04


Date: Sat, 28 Feb 2004 15:00:32 -0600

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);

}