TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: THE MISANTHROPE
from: JERRY COFFIN
date: 1997-04-20 02:15:00
subject: any ideas?

On (03 Apr 97) THE MISANTHROPE wrote to ALL...
 TM>  The following program (under Turbo C++) compiles fine with no
 TM> error but will not link.  Linker reports "Break on Link" with no other
 TM> message to give any clue as to why it doesn't link.
Since you posted this in C_PLUSPLUS, I'm going to guess that you might
not object to a C++ solution to the problem instead of simply fixing the
C version you posted.
#include 
#include 
#include 
class split {
    ifstream in;
    char out_base[FILENAME_MAX];
    char temp_name[FILENAME_MAX];
    void write_chunk(ofstream &out);
public:
    split(char const *in_, char const *output_basename) :
        in(in_, ios::in | ios::binary)
    {
        strcpy(out_base, output_basename);
    }
    int operator()();
};
void split::write_chunk(ofstream &out) {
    char buffer[4096];
    for (int i=0; i<16; i++) {
        in.read(buffer, sizeof(buffer));
        out.write(buffer, in.gcount());
    }
}
int split::operator()() {
    do {
        for ( int i=0; i<999 & !in.eof(); i++) {
            sprintf(temp_name, "%s.%3.3d", out_base, i);
            ofstream out(temp_name, ios::out | ios::binary);
            write_chunk(out);
            out.close();
        }
        if ( !in.eof()) {
            cout << "Please enter base name for next set of chunks.";
            cout  to quit): " << flush;
            cin.getline(out_base, sizeof(out_base));
        }
        if ( 27 == out_base[0])
            return 2;
    } while (!in.eof());
    return 0;
}
int main(int argc, char **argv) {
    if ( argc != 3) {
        cerr << "Usage: split infile outfile-basename";
        return 1;
    }
    split file(argv[1], argv[2]);
    return file();
}
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.