Subj : Re: fstream - opening a binary file in second obj To : borland.public.cpp.borlandcpp From : D Kat Date : Tue Oct 26 2004 12:59 pm I posted that I left the i off of ifstream... that however is not the issue. It still will not open even when declared properly.. "D Kat" wrote in message news:417d62cb$1@newsgroups.borland.com... > Thanks to all the help in this room I was able to clean up code and put > all of the subroutines that student programmers should not play with in a > separate source file that they can now load as an obj file in a project. > However in putting all of the code related to the ISR in this object file > I had to include the fstream binary file that is opened. This code now > will not return anything at all. So when I step through the code the file > stream is empty - so before and after wavefile.open wavefile in WATCH > looks like > wavefile = { }. The ISR is working fine in that the counter in it is > counting just fine. I have not played out a sound file yet because I'm > stuck in not being able to open one. > > > I have checked, double checked, and keep on checking. The file is there, > the name is correct, etc. I have no idea what or where to check at this > point. wavefile is 0. > > Any ideas? > > > > ifstream wavefile; > > int get_stimuli(char *name) //open and read sound file > { > wavefile.open(name,ios::binary); //OPEN > if (!wavefile) > { > cout << "\nCannot open file: "<< name << endl; > return(-1); > } > wavefile.seekg(0,ios::end); // goto EOF > file_length=wavefile.tellg()/2; // get length of file > wavefile.seekg(0,ios::beg); //goto BOF > > for(int i=0;i { > wavefile.read((char*) &wavebuffer[i][0], BUFSIZE*2); // READ file into > buffer > if((readlength[i] = wavefile.gcount()/2)!=BUFSIZE)return(file_length); > } > return(file_length); > } > > .