Visual C++ Problem

Pages: 12
Hello, I've recently started to learn C++ and I've come across an error when trying to run my programs, I am using Microsoft Visual C++ 2008, whenever I try to debug/run my program, it comes up with this code:

The program '[3264] CPP.exe: Native' has exited with code 0 (0x0).

I am asking for your help as I have not an idea what this code means? And how can I fix it so my programs run, thankyou.

Sincerely, Rush.
Last edited on
That's not actually an error...that's the compiler saying your program returned 0 at the end of the code.
So am I doing something wrong ; \? Because my programs don't run they just blink.
Last edited on
No. A return code of 0 means that nothing went wrong.

To fix why your programs just blink have a read through: http://www.cplusplus.com/forum/beginner/1988/
I have tryed by adding those lines but it seems to keep closing.
Have you added a system("PAUSE"), before your return 0?
Yes, but that doesn't seem to make any difference. It still blinks.
closed account (z05DSL3A)
Post your code.
@xtremerocker
system("pause") causes ugly output on the screen and there're more reasons to avoid it. Try to use other solutions, such as cin.ignore(). There has been a big discussion about this toppic: http://www.cplusplus.com/forum/beginner/1988/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>

using namespace std;

void main(void)
{

	int UsersAge = 0;  							//Variables can't have spaces, or numbers before them.
	char Person = 'b';							// char= charatcer type specifier, with characters you use single quotations around them, with strings which means more then one character you use speech marks, with intergers you just leave them as they are.
	
	cout << "What is your age?: " ;
	cin >> UsersAge;


	if (UsersAge >= 0 && UsersAge < = 4)					// if= CPP Command (Coloured Blue), &&= and operator.
	Person = 'b';	
	else  									//second part of if statement. so if it isn't a baby it will move to this part.
	{
	
		if (UsersAge >= 5 && UsersAge < = 20)
		Person = 'y';
		else   								// If you have one line of code under the if statement you don't need the braces "{ }".
		{
			if (UsersAge >= 21 && UsersAge < = 65)		
			Person = 'a';
			else
			{
				
				if (UsersAge >= 66 && UsersAge < = 135)
				Person = 'o' ;
					
				else
				Person = 'x';
					

			}
		}
	}	
		


	if (Person == 'b')
	{

		cout << "Hello there, you are a baby- Because you are " << UsersAge << " years old" << endl ;
		else
		{
		
			if (Person == 'y')
			cout <<	"Hello there, you are a teenager- Because you are " << UsersAge << " years old" << endl ;
			else
			{
				
				if (Person == 'a')
				cout << "Hello there, you are a Adult- Because you are " << UsersAge << " years old" << endl ;
				else
				{

					if (Person == 'o')
					cout << "Hello there, you are a Old Person- Because you are " << UsersAge << " years old" << endl ;
					else
					{
			
						if (Person == 'x')
						cout << "I think you are lying because you are not " << UsersAge << " years old" << endl ;

					}
				}
			}
		}	
	}
			

										// When you have a diagonal "if" it's called cascading.


						



}
There's my code, showing me where I would have to put these other solutions will be appreciated.
closed account (z05DSL3A)
There are some errors in your code, lines 15, 20, 24, and 29 should have <= not < =.
also there are errors with the final if...else if...else block.

Try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>

using namespace std;

void main(void)
{

	int UsersAge = 0;  							//Variables can't have spaces, or numbers before them.
	char Person = 'b';							// char= charatcer type specifier, with characters you use single quotations around them, with strings which means more then one character you use speech marks, with intergers you just leave them as they are.
	
	cout << "What is your age?: " ;
	cin >> UsersAge;


	if (UsersAge >= 0 && UsersAge <= 4)					// if= CPP Command (Coloured Blue), &&= and operator.
	Person = 'b';	
	else  									//second part of if statement. so if it isn't a baby it will move to this part.
	{
	
		if (UsersAge >= 5 && UsersAge <= 20)
		Person = 'y';
		else   								// If you have one line of code under the if statement you don't need the braces "{ }".
		{
			if (UsersAge >= 21 && UsersAge <= 65)		
			Person = 'a';
			else
			{
				
				if (UsersAge >= 66 && UsersAge <= 135)
				Person = 'o' ;
					
				else
				Person = 'x';
					

			}
		}
	}	
		
    if (Person == 'b')
        cout << "Hello there, you are a baby- Because you are " << UsersAge << " years old" << endl ;
    else if (Person == 'y')
        cout <<	"Hello there, you are a teenager- Because you are " << UsersAge << " years old" << endl ;
    else if (Person == 'a')
        cout << "Hello there, you are a Adult- Because you are " << UsersAge << " years old" << endl ;
    else if (Person == 'o')
        cout << "Hello there, you are a Old Person- Because you are " << UsersAge << " years old" << endl ;
    else if (Person == 'x')
        cout << "I think you are lying because you are not " << UsersAge << " years old" << endl ;
    
    //
    // See: http://www.cplusplus.com/forum/beginner/1988/
    system("PAUSE");
    return 0;

}
Thanks, but it is still blinking.
closed account (z05DSL3A)
You will have to give more detail about what you are doing and what you mean by 'blinking'.
Well when I press debug (F5) it opens in a flash and then dissappears as explained on the other thread, but I can't seem to get any of the codes that were given working.
Did you ever got any program running? I guess you're using VS and I'm not familiair with that compiler, but my guess is that you're not running your program, but the debugger, wich will close immidiatly because there arent any bugs. Did you compile the program? Can you find a button with "compile&run" or "run"?

(The program asks for input so it shouldnt blink without system("pause") either)
system("pause") should work in any case, so you must be doing something else wrong. My first guess is that you aren't recompiling.
closed account (z05DSL3A)
Pressing F5 should rebuild the projects if they need it pror to running the program under the debugger.

Rush, Do you have more than one project in the Solution?
@Grey Wolf: No there is just one project.

@Scipio: No I can't see any button with compile and run or run.
Last edited on
Does it even prompt you to enter the age at your cin >> ?
No it doesn't. The program just instantly vanishs with F5 and with CTRL F5 the window stays open but alls it says is "Press any key to continue".
Last edited on
Pages: 12