C++ Program Execution



 DEVELOP > c-Plus-Plus > C++ Program Execution

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 20 Oct 2005 04:37:52 PM
Object: C++ Program Execution
Hello,
I have been getting to know C and C++ alot lately and have come up with
the same problem with each program that I write. When I compile the
program, it comes out with no errors. I can solve those no problem
(usually just a misplaced semicolon) but when it comes to executing the
program to verify my program works correctly, after I input one or
sometimes two variables it closes the window that it is running in. I
have tried using both Visual Studio 2003 and Dev-C++ to compile and run
the programs and it does the same thing in each. Anyone have an ideas
as to why this is happening? I will include code for one that I am just
starting off writing in this post to help you see what is writen.
Thanks in advance for all help recieved.
David
// Code Start:
#include <iostream>
int main()
{
char name;
int age = 0;
std::cout << "Enter your name: ";
std::cin >> name;
std::cout << "Enter your age: ";
std::cin >> age;
std::cout << "\nName: ";
std::cout << name;
std::cout << "\nAge: ";
std::cout << age;
}
// End Code
.

User: "osmium"

Title: Re: C++ Program Execution 20 Oct 2005 04:42:06 PM
<Alexander.David.R@gmail.com> wrote:

I have been getting to know C and C++ alot lately and have come up with
the same problem with each program that I write. When I compile the
program, it comes out with no errors. I can solve those no problem
(usually just a misplaced semicolon) but when it comes to executing the
program to verify my program works correctly, after I input one or
sometimes two variables it closes the window that it is running in. I
have tried using both Visual Studio 2003 and Dev-C++ to compile and run
the programs and it does the same thing in each. Anyone have an ideas
as to why this is happening? I will include code for one that I am just
starting off writing in this post to help you see what is writen.
Thanks in advance for all help recieved.

David

// Code Start:
#include <iostream>

int main()
{
char name;
int age = 0;

std::cout << "Enter your name: ";
std::cin >> name;
std::cout << "Enter your age: ";
std::cin >> age;
std::cout << "\nName: ";
std::cout << name;
std::cout << "\nAge: ";
std::cout << age;
}
// End Code

Try adding this just before the closing brace in main.
cin.get();
.

User: "red floyd"

Title: Re: C++ Program Execution 20 Oct 2005 06:00:08 PM
wrote:

Hello,

I have been getting to know C and C++ alot lately and have come up with
the same problem with each program that I write. When I compile the
program, it comes out with no errors. I can solve those no problem
(usually just a misplaced semicolon) but when it comes to executing the
program to verify my program works correctly, after I input one or
sometimes two variables it closes the window that it is running in. I
have tried using both Visual Studio 2003 and Dev-C++ to compile and run
the programs and it does the same thing in each. Anyone have an ideas
as to why this is happening? I will include code for one that I am just
starting off writing in this post to help you see what is writen.
Thanks in advance for all help recieved.

David

// Code Start:
#include <iostream>

int main()
{
char name;
int age = 0;

std::cout << "Enter your name: ";
std::cin >> name;
std::cout << "Enter your age: ";
std::cin >> age;
std::cout << "\nName: ";
std::cout << name;
std::cout << "\nAge: ";
std::cout << age;

std::cout << std::endl;
cin.get();

}
// End Code

.

User: "Jay Nabonne"

Title: Re: C++ Program Execution 20 Oct 2005 04:55:33 PM
On Thu, 20 Oct 2005 14:37:52 -0700,
wrote:

Hello,

I have been getting to know C and C++ alot lately and have come up with
the same problem with each program that I write. When I compile the
program, it comes out with no errors. I can solve those no problem
(usually just a misplaced semicolon) but when it comes to executing the
program to verify my program works correctly, after I input one or
sometimes two variables it closes the window that it is running in. I
have tried using both Visual Studio 2003 and Dev-C++ to compile and run
the programs and it does the same thing in each. Anyone have an ideas
as to why this is happening? I will include code for one that I am just
starting off writing in this post to help you see what is writen.
Thanks in advance for all help recieved.

If you're debugging it: set a breakpoint on the close brace of main.
If you're not debugging it: run from a separate command window.
- Jay
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER