Thread: Quick question?

  1. #1
    Registered User
    Join Date
    Feb 2003

    Talking 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

  2. #2
    Registered User
    Join Date
    Sep 2002
    Compiler? Platform? OS?

  3. #3
    Post some code... you description is vague at best.
    Best guess: print the filename variable, not the fstream object.

  4. #4
    Registered User
    Join Date
    Feb 2003

    Follow Up

    I'm sorry, I forgot that information.

    Compiler: MingW/GCC 3.2
    Platform: Dev-C++ Version
    OS: Windows XP

    Here is a small sample:

    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++)
 "class_name.dat", ios::in);
    		     if (! data.is_open())
    		            cout<<" file did not open"<< data;
                                                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.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM