Quick question?

This is a discussion on Quick question? within the C++ Programming forums, part of the General Programming Boards category; I am trying to debug a program and need to find out the name of the fstream that the program ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    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
    Kendal

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Compiler? Platform? OS?

  3. #3
    Eibro_Guest
    Guest
    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
    Posts
    184

    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

Popular pages Recent additions subscribe to a feed

Similar Threads

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21