Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Crazy Error Message

Status
Not open for further replies.

lisal

Programmer
Sep 22, 2005
5
0
0
US
I'm running the program below and I enter in the file name and the output file and then a message box appears that reads...

The instruction at "0x00406375" referenced memory at "0xdddddddc". The memory
could not be "read"
Click OK to terminate the application
Click CANCEL to debug the application

*Here is the code That I'm using*

#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>

using namespace std;

#define USE_SAVED_MARKER 0


void ParseOnly(ifstream in, ofstream out);

void main()
{

ifstream in;
ofstream out;

string path = &quot;c:\\projects\\qrt4\\&quot;;
string text = &quot;.txt&quot;;

string filename;
string outfile;

cout << &quot;Enter desired filename: &quot;;
cin >> filename;
filename = path + filename + text;

in.open(filename.c_str());


cout << &quot;Enter output file: &quot;;
cin >> outfile;

outfile = path + outfile + text;
out.open(outfile.c_str());

ParseOnly(in, out);
}

void ParseOnly(ifstream in, ofstream out)
{
...
...
...
}


If anyone can tell me why i'm getting this problem and possibly how to fix it would be greatly appreciated! Thanx...
 
Hi:

I pasted your code into Microsoft VC++ and it compiled and ran without errors.

Is the problem with your function ParseOnly?
 
Debug MFCs fills memory bytes with 0xDC when space is allocated (e.g. before calling the constructor of an object)
and with 0xDD when memory is freed (e.g. after the destructor of the object exits.)

maybe, check your objects life cycle ?

...or flame me if you don't use MCFs :)

Hope it helps.
Jacques.

 
pass the input and output files by reference. By passing them as you are... you are redeclaring them in the function. By doing that you will need to reopen the file if I am not mistaken.

Matt
 
put
cout << &quot;Step n&quot;;
between the existing lines in ParseOut to find out which line is crashing (use a different # for n in each statement).

I also think changing the declaration of ParseOut to
void ParseOnly(ifstream &in, ofstream &out)
would improve things for you.

Rose/Miros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top