Closed Solved

Creating a .cpp in Visual Studio 2010

Ok When I go to new Project to create a new .cpp file for my programming class What are the steps to make sure I am creating the file in the right place I went

1.File>New Project
2. then there are many options for c++ should I be using Empty Project, AtL, MFC DLL, Windows Forms App, CLR Console, Class Library, Custom Wizard, MAkefile Project, MFC ActiveX, Test Project, or Windows Forms Control Library?
I am lost I have tried doing my own codes and ones straight out of the book like


#include <iostream>
using namespace std;

int main ()
{
const double PI = 3.14159;

// Step 1 : Read in Radius
double radius = 20;

//Step 2: Compute area
double area = radius * radius * PI;

//Step3 Display the area
cout << "The area is ";
cout << area << std::endl;

return 0;
}

and I put it inside the CLR Console App and the dos comand pops up for a second then dispaears when I debug should I be compiling to get it to work? also I tried hitting f 11 and when it popped up the dos screen it was blank and when I went back into visual studio it was on a different screen thanks for the hel p ireally appreciate it :)
4 answers Last reply Best Answer
More about creating visual studio 2010
  1. Best answer
    Firstly, decide what type of application you are building. If it's a basic console application that you're doing out of a textbook, choose a Console or Empty Project (probably the former). Most of the others aren't useful for learning purposes. You will need the Windows Forms project type if you later progress to GUI applications, or WPF for newer textbooks that teach that. The project type basically preconfigures your development environment with sane defaults and some auto-generated code (mostly includes and a stub for main, or an empty form for a GUI project). An empty project will simply give you a single blank file and require you to add references as you need them.

    As for your second problem: There are two modes for running the project, Debug and Start without Debugging. The latter will automatically force the application to pause once it has reached the end of its execution and will sit there until you press a key. The Debug option will not do this. Since your program does not contain any line that tells the program to wait, it simply does its calculation, outputs the result to the console and then exits. The easiest solution is just to add a line that waits for user input.

    Also, either Run method will first build the project before executing it, so you don't need to explicitly build and then run ;)
  2. +1 randomizer

    Just pick an Empty Project and either create your files in it, or add existing files.

    And for second problem the best practice is to add a line that waits for user iput.
  3. Best answer selected by hk3008.
  4. This topic has been closed by Nikorr
Ask a new question

Read More

Programming Apps