Visual Studio organizes C++ development around two concepts: solutions and projects. A project is a set of source files, headers, and configuration rules that produce a single output — an executable, a DLL, or a library. A solution is a logical container that groups one or more related projects together, letting them share build configurations and reference each other. When you create a new C++ app in Visual Studio, you create both a solution and a project at the same time. This page walks you through that process for a console application — the simplest type of C++ program and the best starting point for learning the toolchain.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MicrosoftDocs/cpp-docs/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
The Desktop development with C++ workload must be installed before the C++ Console App project template will appear. If you haven’t installed it yet, see the Installation guide.Creating the Project
Open the 'Create a New Project' Dialog
Launch Visual Studio. On the Start Window, click Create a new project. If Visual Studio is already open, use the menu: File > New > Project (or press Ctrl+Shift+N).
Select the Console App Template
In the Create a new project dialog, use the three filter dropdowns at the top to narrow the template list:
- Language: C++
- Platform: Windows
- Project type: Console
Configure the New Project
The Configure your new project dialog has three fields:
- Project name — Enter
HelloWorld. This names the.vcxprojfile and the final executable. - Location — Where on disk to create the solution folder. The default is
Documents\Visual Studio 2022\Projects\. - Solution name — Defaults to match the project name. For a single-project solution this is fine; in larger codebases you might give the solution a different, higher-level name.
Review the Generated Project
Visual Studio creates the solution and project, and opens This is a complete, valid C++ program. The
HelloWorld.cpp in the editor. The generated code looks like this:#include <iostream> line brings in the Standard Library’s input/output stream header. The main() function is the entry point that the operating system calls when your executable starts. std::cout writes text to the standard output stream (the console window).Understanding the Solution Structure
After project creation, the Solution Explorer panel (usually docked on the right or left side) shows the layout of your solution:Solution 'HelloWorld' (root node)
Solution 'HelloWorld' (root node)
The root node represents the
.sln file on disk. A solution can contain multiple projects; right-click the solution to add existing or new projects.HelloWorld (project node)
HelloWorld (project node)
Represents
HelloWorld.vcxproj — the MSBuild project file that stores all build settings, compiler flags, preprocessor definitions, and file lists.Source Files
Source Files
A virtual filter grouping your
.cpp implementation files. Right-click here to add new or existing C++ source files. The actual files live on disk wherever your project folder is — the filter structure in Solution Explorer does not have to match the folder structure on disk.Header Files
Header Files
A virtual filter for
.h and .hpp files. Header files are not compiled directly; they are #include-d by source files.External Dependencies
External Dependencies
Shows headers from the Windows SDK, the C++ Standard Library, and any other include paths configured in the project. These are auto-discovered by IntelliSense and are read-only.
Key Files on Disk
Navigate to your project folder in File Explorer to see the files Visual Studio created:| File | Description |
|---|---|
HelloWorld.sln | Solution file. Open this in Visual Studio to load the solution. |
HelloWorld\HelloWorld.vcxproj | The MSBuild project file containing all build settings. |
HelloWorld\HelloWorld.vcxproj.filters | Defines the virtual folder structure shown in Solution Explorer. |
HelloWorld\HelloWorld.cpp | Your main source file. |
The
.vs\ hidden directory next to the .sln file stores local user settings (window layouts, recently opened files, IntelliSense caches). It should generally be added to .gitignore and not committed to source control.Understanding the Generated main() Function
Themain() function is the program’s entry point. For a console application, the operating system calls main() at startup and the program exits when main() returns. The return value (an int) is the program’s exit code — 0 conventionally means success, any non-zero value indicates an error.
main with command-line parameters:
Adding More Source Files
Real projects are split across multiple files. To add a new.cpp or .h file:
- Right-click Source Files (or Header Files) in Solution Explorer.
- Choose Add > New Item… (or press Ctrl+Shift+A).
- Select C++ File (.cpp) or Header File (.h), give it a name, and click Add.