Please help. I've been programming with C++ on Windows for years, but all of a sudden my code will not work. I was using Dev-C++, I'm now using Code::Blocks, although the error still persists. Here is my program:
1 2 3 4 5 6 7
#include <iostream>
usingnamespace std;
int main(void){
int n=42;
cout<<n;
return 0;
}
Code::Blocks says it's returning 0xC0000005, which seems to be saying that I have no right to access n. But I should... right?
Using stdio.h and printf to display n works fine,
and just printing text with cout works too
Have you tried stepping through it with a debugger? Have you checked the md5 on your build of your compiler (e.g. MinGW)? It is possible that maybe the libraries you are linking to have some problems. At any rate, try stepping through with the debugger, and when it crashes, find the call stack to see what function(s) caused it to crash.