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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Violation error??

Status
Not open for further replies.

golyg

Programmer
Jul 22, 2002
319
US
Hi all,
i am trying to set a variable through a pointer but I keep recieving an "Unhandled Exception in app.exe Access Violation" error.

Any ideas why?

thanks
 
Hi

Suppose a int variable and a pointer to it:
int nData = 2;
int* pnData = &nData;

Change the value as:

*pnData = 10;

Suppose you pass a pointer to a int in a function as:
void TestFunction( int* pnData)

To set up a variable in this function, use

*pnData = 5;

HTH

Thierry
 
I think I may have mislead the problem, here is variable and a call to a function:

nNewStatus = 0;
m_pDoc->SetChargeStatus(nNewStatus);

---------------------------------------------------------

here is the function:
void CACMSDoc::SetChargeStatus(int nNewStatus)
{
m_nNewStatus = nNewStatus;
}


in the function, m_nNewStatus throws an exception.
thanks for the help,
m
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top