From: Tim Newsgroups: comp.os.msdos.djgpp Subject: Re: Is this a bug with DJGPP? Pls Help. Date: Mon, 26 Oct 1998 11:14:47 -0700 Organization: The University of Calgary Lines: 76 Message-ID: <712e6q$c1i@ds2.acs.ucalgary.ca> References: <70thdn$kfe AT ds2 DOT acs DOT ucalgary DOT ca> <711qg3$hbq$2 AT antares DOT lu DOT erisoft DOT se> NNTP-Posting-Host: tssymanc AT acs2 DOT acs DOT ucalgary DOT ca Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Sender: tssymanc AT acs2 DOT acs DOT ucalgary DOT ca In-Reply-To: <711qg3$hbq$2@antares.lu.erisoft.se> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On 26 Oct 1998, Martin Stromberg wrote: > Tim (tssymanc AT ucalgary DOT ca) wrote: > : I2luY2x1ZGUgPGZzdHJlYW0uaD4NDQojaW5jbHVkZSA8aW9zdHJlYW0uaD4N > : DQoNDQppbnQgbWFpbigpew0NCg0NCiAgICAgICAgY2hhciB0ZXh0WzI2XTsN > > If you want feedback, post something readable. > > Right, > > MartinS I don't know what happened, I can read both my post and attachment perfectly... Anyhow I'll try this again. My problem is with the following code, when I set number = 996546 the thing runs golden, but when number = 888888, the thing screws up, it reads back in the wrong number (It reads back in something like -32000). I've tested the same code with CC and g++ and it worked fine with both. Anybody know why DJGPP is giving me the grief? Did I do something wrong? Did I break some convention that I don't know about? --------------8<------------------------------------8<------------------------------- #include #include int main(){ char text[26]; int number; for(int x = 0; x < 25; x++) text[x] = (x % 10) + '0'; text[25] = '\0'; number = 888888; cout << "Before going through the file : " << endl; cout << text << endl; cout << number << endl; fstream file; file.open("data", ios::out); file.write(text, sizeof(text)); file.write((char *) &number, sizeof(number)); file.close(); text[0] = 'N'; // TO SHOW IF THE STUFF IS ACTUALLY GETTING READ text[1] = 'o'; // text[2] = 'p'; // text[3] = 'e'; // text[4] = '!'; // text[5] = '\0'; // number = 0; // file.open("data", ios::in); file.read(text, sizeof(text)); file.read((char *) &number, sizeof(int)); file.close(); cout << "After going through the file : " << endl; cout << text << endl; cout << number << endl; return(0); } -------->8---------------------------------------->8---------------------------------- Any help would be appreciated. Thanks, -Tim