I'm a newb at C++, I just started today, and I know my program is coded right because I followed a tutorial and I checked like 50 times, and for some reason, my program compiles fine, but when I run it, all it says is: "Press any button to continue" (Which I assume is from system"pause") and it doesn't show any of the other stuff I put! Please help!
Like this? Oh and remember, this is like the second most basic program out there
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <windows.h>
#include <iostream>
#include <cmath>
#include <cstdlib>
usingnamespace std;
int main()
{
int A = 5;
int B = 10;
int C = A + B;
cout << C << endl;
system("pause");
}
There's nothing wrong with the code, is this the first program you've made? Must be something wrong with your compiler I'd guess, what compiler are you using?
well, other users on this site seem to think using system("pause") is a bad idea. maybe try it without that? and also to save you some flak from others :P
edit: and add return 0. you need it in main; I don't have a good explanation though
I tried to try visual studio 2010 express, but I couldn't figure out how to download it. I went to the site, but I didn't see any link anywhere. And why is Dev c++ terrible?
Don't include headers that you don't need. You're not using anything from windows.h or cmath so they shouldn't be included. This is one of my pet hates of programmers brought up on visual studio.