Original Post
Why am i getting access violation error from windows and not debugger from the following program... what is wrong with it?
I hope somebody can help me.
#include <iostream>
using std::cout;
using std::endl;
int maxnodes = 20;
int i;
struct listNode
{
int data;
struct listNode *nextPtr;
};
void main()
{
listNode node[19];
for( i = 0; i <= maxnodes; i++)
{
node[i].data = i;
if(i == 19)
{
node[i].nextPtr = 0;
}
else
node[i].nextPtr = &node[i+1];
}
listNode *iterator = &node[0];
while (iterator != 0)
{
cout << iterator->data << endl;
iterator = iterator->nextPtr;
}
}