From: Rodeo Red Newsgroups: comp.os.msdos.djgpp Subject: Re: missing Date: Sun, 30 Jan 2000 10:13:23 -0500 Organization: Church of Evangelical Environmental Extremism Lines: 144 Message-ID: X-Orig-Message-ID: <38945513 DOT 3D8E7D5F AT netstep DOT net> References: <38910E6A DOT DF22D15A AT americasm10 DOT nt DOT com> <389169e4$1 AT news DOT uni-bielefeld DOT de> Abuse-Reports-To: support at netstep.net to report improper postings NNTP-Proxy-Relay: library2.airnews.net NNTP-Posting-Time: Sun Jan 30 09:10:25 2000 NNTP-Posting-Host: !\DtK-@[.=N"J8s (Encoded at Airnews!) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Manni Heumann wrote: > > Standard headers in C++ don't come with a suffix. > libgpp should not be necessary for C++, you only need it to compile legacy > code (e.g. to compile programs that use the String class). > > But what sort of functionality should contain? It opens a file for output. from my text books it seems to be part of the standard library. AFAIK, that measn it should be in djgpp and I probably lost it. It would be nice if someone could simply verify whether or not AFAIK once you include you don't have to worry about the subclasses. > Try to change the #include lines below with this: > #include > #include > > I bet it will compile then. Those headers are already included. If I just erase "#include " the program compiles but doesn't work correctly. I get a message telling me a file failed to open. The program is pretty short, so here it is: I'm trying to learn how to open and manipulate files: // liner.cpp // Example of reading and writing text files and // defining personal iomanipulators #include #include #include #include #ifndef MAXPATHLEN const int MAXPATHLEN = 255; #endif const std::string PROG = "liner"; const int MAJOR = 0; const int MINOR = 1; std::ostream & Prog ( std::ostream & stream ) { stream << "\n" << PROG << " Version: " << MAJOR << "." << MINOR << std::endl; return (stream); } std::ostream & Sepline ( std::ostream & stream ) { stream << "------------------------------------------------------------------" << std::endl; return (stream); } int main ( int argc, char * argv[] ) { char inputfile[MAXPATHLEN] = {0}; char outputfile[MAXPATHLEN] = {0}; if ( argc < 2 ) { std::cerr << Prog << Sepline << "Syntax: " << PROG << " inputfile " << std::endl; return(1); } strcpy ( inputfile, argv[1] ); std::ifstream input( inputfile, std::ios::in ); std::ofstream output; if ( input.is_open() == false ) { std::cerr << Prog << Sepline << "Failed to open: " << inputfile << std::endl; return(2); } std::cout << Prog; if ( argv[2] ) { strcpy ( outputfile, argv[2] ); output.open ( outputfile, std::ios::out ); if ( output.bad() ) { std::cerr << Sepline << "Failed to open: " << outputfile << std::endl; return(3); } else { std::cout << "Output File: " << outputfile << std::endl; output << Prog; output << Sepline; } } std::cout << Sepline; char buffer[MAXPATHLEN] = {0}; int counter = 0; int bytes = 0; while ( !input.eof() ) { input.getline ( buffer, MAXPATHLEN ); bytes += strlen(buffer); counter++; std::cout << counter << "\t| " << buffer << std::endl; if ( output.good() ) { output << counter << "\t| " << buffer << std::endl; } } std::cout << Sepline; std::cout << "Lines in file: " << counter << std::endl; std::cout << "Bytes in file: " << bytes << std::endl; if ( output.good() ) { output << Sepline; output << "Lines in file: " << counter << std::endl; output << "Bytes in file: " << bytes << std::endl; } output.close(); input.close(); return(0); }