Thread: I think it's with the Heap...but is it...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Meganan
    Join Date
    Oct 2005
    Posts
    13

    Lightbulb I think it's with the Heap...but is it...(solved)

    I have some code that is supposed to dig right into a file and return the text it finds (it's a big file). Unfortunately for me it compiles properly but crashes in the actual program; this is what leads me to beleive the problem is with the heap. My code is below:

    Code:
    char* file_get(char* fdest)
    {
    	fstream file(fdest,ios::in);
    	
    	char* temp = new char;
    	*temp = 0;
    	if(file.is_open())
    		while(!file.eof())
    			file.getline(temp, 1000000);
    	file.close();
    	return temp;
    }
    
    int main()
    {
            char* temp = file_get(dest);
            cout << temp;
            delete temp;
            return 0;
    }
    I have included a required headers etc. etc. So what am i doing wrong?
    Last edited by Meganan; 10-05-2005 at 10:33 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. heap
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 11-10-2007, 11:49 PM
  2. Heap Work
    By AndyBomstad in forum C++ Programming
    Replies: 1
    Last Post: 05-16-2005, 12:09 PM
  3. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  4. heap question
    By mackol in forum C Programming
    Replies: 1
    Last Post: 11-30-2002, 05:03 AM
  5. stach and heap.
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 01-26-2002, 09:37 AM