Subj : Re: fstream arrays To : borland.public.cpp.borlandcpp From : "Dwayne" Date : Tue Feb 24 2004 03:51 pm Hello D Kat, /////////////////////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); } A few other things. 1. Clear the variable "Name". Assign it to all blanks I realize that strcpy puts a NULL terminating character on the end of the copy, but it may help in the debugging. 2. make sure you use "Forward Slashes", not back slashes. in the "copy" and "Cat" commands. That way the compiler will not think it is a "special" character... like \0. or \\. 3. This may sound crazy, but it may solve your problem.... Build your string with a strins command. Do not use the Strcat. You may be building it backwards from what you are doing, but hey! the result is the same.... 4. Are you using something like Memcheck? There is a very good chance that you are overwriting your memory someplace. and you may not be seeing it until now. Strcat is a dangerous command for overwriting memory if you are not careful. strcpy(name,"data/"); strcat(name, sub_name[file]); strcat(name,"."); strcat(name,cdn); changes to: strcpy(name,cdn); strins(".",name,0); strins("sub_name[file],name,0); strins("data/",name,0); Here is a source for a strins.... int strins(char *r, char *s, int p) { int c,d; d=0; c=-1; while(d=p+d;c--) { *(s+c+1)=*(s+c); } *(s+p+d)=*(r+d); d++; c=0; } return(c); }; .