-
Quick question?
I am trying to debug a program and need to find out the name of the fstream that the program is opening. Every time I cout the fstream, it give me the address instead of the filename. I have tried everything I know. How can I cout the filename instead of the address????
Please Help
Most Grateful
Kendal
-
-
Post some code... you description is vague at best.
Best guess: print the filename variable, not the fstream object.
-
Follow Up
I'm sorry, I forgot that information.
Compiler: MingW/GCC 3.2
Platform: Dev-C++ Version 4.9.7.6
OS: Windows XP
Here is a small sample:
Code:
void read_data(string ID,istream& in)
{
fstream data;
char class_name[10];
int counter = 0;
string ident;
char mark;
while (counter<7)
{
for (int j=0;j<1;j++)
{
in>>class_name;
cout<<class_name;
system("pause");
data.open("class_name.dat", ios::in);
if (! data.is_open())
cout<<" file did not open"<< data;
else
cout<<" file did open"<< data;
I know that class_name is supposed to be the filename, but I was wanting to debug to be for certain what filename was stored in data. Because when this section of code runs, the "file did not open" line runs and at the time there is a file of that name that does exist in the directory. How do I print out the filename in data. And I have tried to store data's contents in a string, but it will not let me make the conversion.
Thanks for the reply.
Any info will be greatly appreciated.
Gratefully,
Kendal