Subj : Re: fstream arrays To : borland.public.cpp.borlandcpp From : "D Kat" Date : Wed Feb 25 2004 03:44 pm I have stepped through the code to check all of these issues and they are not a factor (this is old code that is a hold over from pre-c++ days but the function is basically the same). As said in other post - this is run in DOS and the names are always less than 6 chars + 1 '.' +3 extension char + 1 '\0'. //CODE WHICH CALLS THE FILE OPEN FUNCTION void write_data(int numstim) { int ns,stim; for (ns = 0; ns < num_sub; ns++) { if (get_subj_fp(ns) == 1);//ERROR returns error which is ignored for (stim=0;stim wrote in message news:403cfce6$1@newsgroups.borland.com... > DKat, > > 1. Is 20 characters enough for name? > You don't show what sub_name or cdn actually is. > > 2. I would suspect you're trying to open a file that's already open. > Where do you close the file? > > Ray Sittig > > > /////////////////////CODE//////////////////////////////// > > ofstream out_files[NSUB];//file to write data to > > 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); > > } > > > > > > .