a very simple question about visual c++

hi, i'm using visual c++ express 2008.
i have built a project called helloworld.
under this project i created a source file, it contains code which writes "hello" on screen.
then, i created another source file under the same project, which adds 2 integers and displays on screen.
when i try to run the second program, it runs the first program.
how do i run the second program???
On the solution explorer, right click on the newer project > Set as StartUp Project.
It's always better to run programs from the console, though. Don't start the debugger needlessly.
Last edited on
helios, i didn't create another project. i created another source file under the same project. when i am on the new source code window, i press the "start without debugging" button, but it runs the first source code. how do i get the second source code run?
Would you care to post the code for both .cpp files?
this is the first source file:

// first c++ program, b.
#include <iostream>

// main function starts here
int main()
{
std::cout <<"Welcome \nto\n\nC++!\n\a"; // this message will be displayed on screen
return 0;
}


this is the 2nd:

#include <iostream> //this line allows to program to perform input and output

int main2() //main function starts here
{
//variable declarations
int number1;
int number2;
int sum;

std::cout <<"Please enter first integer: \n";
std::cin >> number1;

std::cout << "Please enter second integer: \n";
std::cin >> number2;

sum = number1 + number2;

std::cout << "The sum of integers is: " << sum << std::endl;
return 0;
main2()? What?

A single project can only create a single executable. The entry point for programs is always main(), and nothing else.
so, i have to create another project to run the second program?
if yes, what is the use of multiple source files under same project?
what is the use of multiple source files under same project?
Organization and convenience.
Topic archived. No new replies allowed.