I am developing a software for data acquitition using vc++6.0.

During the course of the program I am getting a fatal error OE. On investigating the fatal error 0E, I realised that this is a page fault.

I am getting this error while I am setting a text in an edit window of a dialog box.If I comment the code line in which I have used SetWindowText , The fatal error is eliminated. I am not able to reason out the problem. I have also used _out and _inp for addressing the data acq. card.

I am writting the code below.

//First get the text from the edit box.m_filename1 is a member
//variable of edit box

CString strin1;
m_filename1.GetWindowText(strin1);
char name1[50];
strcpy(name1,LPCTSTR(strin1));

// some outport & inport commands for card interfacing

_outp(portA+4,nlow);
_outp(portA+5, nhi);
dtl = _inp(portA);
dth = _inp(portA+1);

//Opening a file of name fetched by the text box and saving
//some data in it and then closing the file.
ofstream file (name1);
file<<"OUTPUT VOLTAGE"<<" "<<"VOLTAGE(V1) ";
file<<"VOLTAGE(V2) "<<"RATIO(V1/V2) "<<"\n"; file<<temp;
file<<"\n";
file.close();

// outporting certain values again before exit
n = 0;
_outp(portA+4,n);
_outp(portA+5, n);

// Changing the name of the file to be used for storing the next
//run by incrementing the number and adding it to the filename
//string
incr = incr+1;
strcpy(name1,name);
char addon[10];
itoa(incr,addon,10);
strcat(name1,addon);

// (name1) now contains the string to be used as the next file
//name. BELOW IS THE LINE THAT IS CREATING THAT FATAL
//ERROR. IF I COMMEMNT THIS LINE , THE PROBLEM IS SOLVED
//BUT HOW WILL I THEN WRITE THE NAME OF THE NEXT FILE IN
//THE EDIT BOX.
m_filename1.SetWindowText(name1);

I am stuck in the above problem.

How to remove the exception invalid page fault or fatal exception 0E.

Help me if you can.

juhi