Extremely basic program wont work

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!
Last edited on
Not sure how you expect us to help without seeing your code...post your code, in code tags.
Last edited on
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>
using namespace 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?
Other than "Hello, world!", this is my first program, and I'm using Dev C++
EDIT: Hello world worked fine by the way
Last edited on
I'm trying reinstalling Dev C++ to see if that helps.
EDIT:
Okay, that fixed it.
Last edited on
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
Last edited on
Don't use Dev-C++ it's terrible. I use visual studio 2010 express, a lot of people love CodeBlocks and for good reason. Try one of those.
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?
Okay, for me, that's a good enough reason to visual studio 2010 express. I thank you for that.
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.
Topic archived. No new replies allowed.