Newsgroups: comp.lang.c++ Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cunixf.cc.columbia.edu!cs.columbia.edu!kyt From: kyt@cs.columbia.edu (Kok-Yong Tan) Subject: Sucking in a mixture of int's and unsigned char's Message-ID: Sender: news@cs.columbia.edu (The Daily News) Organization: Columbia University Department of Computer Science Distribution: comp.lang.c++ Date: 13 May 91 05:52:14 I'm trying to read in image data from a file in IMPROC format: the first 8 bytes are read in as two int's (the width and height of the image) and the rest of the file consists of width * height unsigned char's. I've declared the following : ifstream InBuf(FileName, ios::nocreate); int Width; int Height; and when I try to extract the first 8 bytes with: InBuf >> Width; InBuf >> Height; I keep getting zeros when I know that it should be a 32 x 32 image and this data is encoded in the first 8 bytes of the file. I notice that InBuf >> DataBuffer[Index]; // DataBuffer is declared as an array of // unsigned char. seems to work fine. Since operator >> (int&) is defined, I would've thought that the "InBuf >> Width" and "InBuff >> Height" would work similarly. What did I do wrong? Thanks for any help. -- Kok-Yong Tan can be reached at: | "Labra lege." InterNet: kyt@cunixa.cc.columbia.edu | - George Bush, if he were Caesar CompuServe: 75046,256 | Everything that can possibly be America Online: lallang | disclaimed is hereby disclaimed.