My brain must ave rolled back too. Can someone point out why this is giving me an error (actually a windows error) when i run it, though it compiles with no errors in MV c++?

#include <iostream>

using namespace std;

int returns300()
{
	return 300;
}
 
void main()
{
	int ia[300];
ia[returns300()] = 20000;
 
}

You've got an off-by-one error. The elements of your array are numbered 0..299.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.