Hey Guys, So I am trying to implement a socket program that will allow me to transfer data from a machine and monitor it remotely. Having issues with a particular part of this program. I am a newb to programming and I would greatly appreciate any help. The error I get is:
Unhandled exception at 0x0040196b in haas.exe: 0xC0000005: Access violation reading location 0x00000000.
Call Stack:
> haas.exe!main(int aArgc, char * * aArgv) Line 46 + 0x3 bytes C++
msvcr100.dll!_initterm(void (void)* * pfbegin, void (void)* * pfend) Line 873 C
/* Construct the adapter and start the server */
HaasSerial *serial = new HaasSerial(aArgv[i], 19200, "none", 7, 1, debug);
HaasAdapter adapter(port, serial, positions);
adapter.startServer();
return 0;
}
The line of code where it points for the error is:
while (aArgv[i][0] == '-' && aArgc > 0)
I really need help getting this program to run ASAP. Thanks guys!
aArgc is the count of the elements in aArgv. First you get a element, and then you check if there are actually elements. The process always goes from left to right, so...
Code:
while (aArgc > 0 && aArgv[i][0] == '-')
.. by switching the checks you first check if there are elements, and then use the elements.
Code:
int i = 1;
Every arrays starts at 0, not at 1.
Last edited by Skizmo; September 6th, 2010 at 12:20 PM.
Bookmarks