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

Code:

#include "internal.hpp"
#include "haas_adapter.hpp"
#include "server.hpp"
#include "string_buffer.hpp"

int main(int aArgc, char *aArgv[])
{
int port = 7878;
int i = 1;
bool debug = false;
bool positions = false;

while (aArgv[i][0] == '-' && aArgc > 0)
{
if (aArgv[i][1] == 'd')
debug = true;
else if (aArgv[i][1] == 'p')
positions = true;
else
{
printf("Invalid option: %s\n", aArgv[i]);
printf("Usage: %s [-dp] <Serial_COM> [port]\n", aArgv[0]);
exit(1);
}

i++;
aArgc--;
}

if (aArgc > 2)
port = atoi(aArgv[i + 1]);

/* 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!