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!

memory cannot be read and access violation

Status
Not open for further replies.

dalelmaghrebi

Programmer
Oct 20, 2002
5
TN
hi every one
while excuting my program, an error message appears
the instruction at ... uses the memory adress 0x00000000. the memory cannot be read
and when i click on ignore, i recieve an other message: unhandled exception in **.exe: 0xc0000005 access violation..
any one can help me
thank you in advance
 
I suspect that you have a memory addressing problem. It appears, although it's difficult to determine without the source code, that you are attempting to read memory at an invalid address. This most likely is caused by an invalid pointer in your code.

I suggest you step through your code using the debugger and identify where the error is located and examin the pointer logic.

Good Luck!
/jerry
 
hi,
the access violation !

this appens when you put a value as 0 or other,
inside a pointer; a little example :

char *p ;

*p=0 ; // works fine
printf(p); // does not print, but does not bomb !


p=0 ;
printf(p); // says to system to go to read at address 0:
// the system safe itself and bombs out your program.

Obviously, in a real program, the thing are not so simples,
but the concept is the same. To find where this appens, you
have to:

1) put your code in debug and step it

or

2) bisect your code, and, calling or not calling,
find the section in which your program is "outed" by the OS

Typically this appens in the new system-call inserted in the code: a parameter wanted pass by ref,is passed by val:

int byteread=10;
cha buf[10];

rc=receive( byteread, buf, channel ) ;

instead of

rc=receive( &byteread, buf, channel ) ;

some fields are used in both dirs: input and output:
in above case, you tall to system-call the maximum char
you want receive (ie: bufsize): the system-call fills
the buffer and returns in another field how many;


bye
to you the data
 
thank you
my problem is resolved due to your advices..
now my program can be executed successfully. however i still have one problem..
in fact my program was developed to read some measured data. my data acquisition system consits of sensors, a resistance to voltage converter and an AD converter.
data are collected in an excel file..
the problem is that i cannot get data and the excel file is not found.
the i/o channels of the AD converter are checked. the problem should be related to the other circuit. any way i wonder why the excel file cannot be open even if data can not be measured
thank you for help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top