delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/17/18:03:06

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: lbrtchx AT hotmail DOT com (CPPNewbie)
Newsgroups: comp.os.msdos.djgpp
Subject: no matching function for call
Organization: Acecape, Inc.
Message-ID: <1008615695.246552@news>
Cache-Post-Path: news!unknown AT p66-243 DOT acedsl DOT com
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)
Date: 17 Dec 2001 22:57:41 GMT
Lines: 66
NNTP-Posting-Host: f4ff500e.news.newshosting.com
X-Trace: DXC=:45G5XWdO=F<RHE`Qmbk4MX`1N4>^k1LCiF6BbIV4YYBLnHEXCOOR AT OENV?o;G=DOI\4CTT1l\<3F??2mKW>l_IC
X-Complaints-To: abuse AT newshosting DOT com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

  Hi,

  I was testing code that I was able to run using VC++6 without a hitch, but djgpp is giving me the compile time error:

 no matching function for call to 
`std::basic_ofstream<char, std::char_traits<char> >::write(unsigned char*&, unsigned int)'
c:/djgpp/lang/cxx-v3/bits/ostream.tcc:

 because I try to read data from and write to files using 

ofstream's  .write((unsigned char*) &ut, sizeof(unsigned char))

 and 

 unsigned char* ucAr = new unsigned char[ASCIIVOL]; 
 ifBinStrm.read((unsigned char*) ucAr, ASCIIVOL); 

 Is there a way to make the compiler/linker swallow these kinds of C-like code and keep going?

 My question would be then. How do you read/write a number of raw bytes from/to a file?

 Thanks

// - - - - - - CODE EXAMPLE - - - - - - - -

#include <fstream.h> 

// __ Constant  
const unsigned int ASCIIVOL = 256; 

int main(void){
 unsigned int ut, utStrt = 0, utTp = ASCIIVOL; 

// __ writing byte size binary data 
 ofstream ofBinStrm; 
 ofBinStrm.open("TmpFl.bin.", ios::out|ios::binary); 
 for(ut = 0; (ut < utTp); ++ut){ ofBinStrm.write((unsigned char*) &ut, sizeof(unsigned char)); } 
 cerr << " ofBinStrm.tellp()=" << ofBinStrm.tellp() << endl; 
 ofBinStrm.close(); 

// __ Opening file as ifstream 
 ifstream ifBinStrm; 
 ifBinStrm.open("TmpFl.bin.", ios::in|ios::binary); 

// __ Dumping file at once on the array 
 unsigned char* ucAr = new unsigned char[ASCIIVOL]; 
 ifBinStrm.read((unsigned char*) ucAr, ASCIIVOL); 
 cerr << " ifBinStrm.tellg()=" << ifBinStrm.tellg() << endl; 
 ifBinStrm.close(); 

// __ printing array 
 for(ut = 0; (ut < utTp); ++ut){
  cerr << ut << "," << (unsigned int)ucAr[ut] <<", ucAr[" << ut << "]=" << ucAr[ut] << endl;
 }
 delete[] ucAr;
// __ 
 return(0);
}//  main 
 
 


 

 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019