Archived

This topic is now archived and is closed to further replies.

OglaHai

Need help finding out why I have a NullReferenceException in this code

Recommended Posts

OglaHai    122
I can get the code to compile, but upon execution I receive that error. Here it is below: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Hex.Set_x_coordinate(Hex* , UInt16 x) in c:\documents and settings\adminis trator\my documents\visual studio projects\b\b.cpp:line 25 at create_generic_map() in c:\documents and settings\administrator\my documen ts\visual studio projects\b\b.cpp:line 452 at main() in c:\documents and settings\administrator\my documents\visual stud io projects\b\b.cpp:line 590 When I run the compiler in debug, I get the following values for some of the variables: this null Hex* x 1 '''' unsigned short x_coordinate 0 '''' unsigned short I''d say that the null error has something to do with the Hex* being set to null, but I have no clue how to correct it if that is causing the error. Since I don''t know how to create a box to put code in, I''ve uploaded the source to the following address: http://members.aol.com/oglahai/universe_pbem_software.cpp I''m not very good at programming, so please forgive the horrid code. Any help at all, or comments would be greatly appreciated. Thanks, Ken

Share this post


Link to post
Share on other sites
ShadowWolf    154
strcpy is used like this:

strcpy( destination, source )

The following:

Line 87: strcpy ("Void",hex_name);

is trying to copy the contents of hex_name to "Void" which ain''t gonna work. Reverse it and see what happens.

Share this post


Link to post
Share on other sites
OglaHai    122
Thanks for pointing out the strcpy error.

I fixed it and the error still shows up.

I''ve tried to find how to disable managed extensions, but haven''t figured out how to do so yet.

I''m trying to use .NET instead of VC++ 6 for a compiler and have other problems with it, could that have something to do with the error I''m getting?

Thanks,
Ken

Share this post


Link to post
Share on other sites