Subj : Re: fstream arrays To : borland.public.cpp.borlandcpp From : " Bruce Salzman" Date : Wed Feb 25 2004 04:14 pm > if(!out_files[i]) ...... tests as 1 or as an ERROR > if(!out_file).... tests as 0 or NOT ERROR. > > ofstream outfiles; > vs > ofstream outfiles[3]; > > Why does one return false while the other doesn't - BOTH successfully > open, write and save. I can't reproduce what you are seeing. How many files are you trying to open? There is no real diffence between the single stream and the array version you cite except the latter opens 3 streams instead of one. Here is the code I tested (which does not show any error messages): #include #define NSUB 10 char *cdn="txt"; char *sub_name[NSUB]={ "FILE1", "FILE2", "FILE3", "FILE4", "FILE5", "FILE6", "FILE7", "FILE8", "FILE9", "FILE10", }; ofstream out_files[NSUB];//file to write data to int get_subj_fp(int file) { char name[20]; strcpy(name,"./data/"); strcat(name, sub_name[file]); strcat(name,"."); strcat(name,cdn); out_files[file].open(name); if (!out_files[file]) { cerr << "\nerror on file " << sub_name[file] << "\n"; return(1); } return 0; } int main(int argc, char* argv[]) { int i; for (i=0; i< NSUB; i++){ get_subj_fp(i); } for (i=0; i< NSUB; i++){ out_files[i] << "hello, world\n"; } return 0; } Regards, Bruce .