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

I am experiencing a problem while setting a text in the dialog box.

Below is the code for writing text in the window

// The code below gets the name of the file from the edit box (whose instance is given by the name m_filename1//
CString strin1;
m_filename1.GetWindowText(strin1);
char name1[50];
strcpy(name1,LPCTSTR(strin1));
// The code below outputs a data at a specific port

nlow = ( n & 0x000f);
nlow = nlow * 16;
_outp(portA+4,nlow);
int nhi = (n & 0x0ff0);
nhi = nhi/16;
_outp(portA+5, nhi);
//opening a file and writing the data and then closing it.
ofstream file (name1);
file<<"OUTPUT VOLTAGE"<<" "<<"VOLTAGE(V1) ";
file<<"VOLTAGE(V2) "<<"RATIO(V1/V2) "<<"\n";
file<<temp;
file<<"\n";
file.close();
// outputing 0 at the data port for exiting
n = 0;
_outp(portA+4,n);
_outp(portA+5, n);
// changing the name of the file by adding a number to the file
//name and incrementing it for the next operation(data
//acquisition)
incr = incr+1;
strcpy(name1,name);
char addon[10];
// THE CODE LINE BELOW GIVES THE FATAL ERROR
m_filename1.SetWindowText(name1);

If I comment the above line the program runs fine. I am not able to find the bug.

The error generated is invalid page fault in module KERNEL32.DLL

I am looking forward for some replies.


juhi