How to open a .cpp file
Quick, free ways to open C++ on any system.
A .cpp file is a C++ Source File. If double-clicking does nothing, your computer simply does not have an app that reads C++ yet. Here is how to fix that on each operating system, using free software wherever possible.
Open a .cpp file step by step
- Confirm the file really is a .cpp. Drop it into the WhatFileType file identifier, which reads its signature without uploading anything.
- On Windows, open it with Visual Studio or VS Code.
- On Mac, use Xcode or VS Code.
- On Linux, try VS Code or vim.
- Still stuck? Convert the .cpp to exe (via a compiler), which opens more widely.
Best apps to open .cpp files
Windows
- Visual Studio
- VS Code
- any text editor
macOS
- Xcode
- VS Code
- any text editor
Linux
- VS Code
- vim
- g++ / clang++
!
Before you open it: Caution. A .cpp file is program source. Compiling and running it executes its code; review untrusted files first.
Frequently asked questions
Why can't I open my .cpp file?
Almost always because no installed app understands C++. Install one of the apps above, or convert the file to a format your existing software already reads.
How do I compile a .cpp file?
Use a C++ compiler: g++ file.cpp -o program then run it, or build it in Visual Studio, Xcode or VS Code.
What is the difference between C and C++?
C++ builds on C, adding classes, templates and a rich standard library while keeping C's speed. Most C code also compiles as C++.