Folders

How to open .C files (C and C++ source code) on Android, Windows and Linux

What .c, .h and .cpp files are and how to open, read and edit C, C++ and Objective-C source code for free on Android, Windows and Linux, with no IDE needed.

Cover: Folders' text editor on two phones, labelled .C

A lecturer emails you main.c and list.h, or you download a project from GitHub to look at on the train. Your phone says there’s no app for the file, and on a PC Windows asks which program to use, or offers Visual Studio if it happens to be installed.

These are plain text files full of source code. Folders opens them in its text editor, with colours for the code and line numbers down the side, on Android, Windows and Linux, and you can fix a line and save it there too.

What is a .c file?

A .c file holds source code in C, the language Dennis Ritchie created at Bell Labs in the early 1970s. It’s ordinary text: a compiler such as GCC, Clang or Microsoft’s MSVC reads it and turns it into a program. Operating systems, device firmware and many libraries are still written in C.

C programs come in two kinds of file. The .c files hold the code. The .h header files hold declarations (function names, types, constants and macros) that other files pull in with a line like #include "list.h".

C++, which grew out of C, never settled on one extension, so several mean the same thing. Objective-C, the language of Apple’s apps before Swift, uses another pair.

Extension Language or format What it’s for
.c C Source code that gets compiled
.h C or C++ header Declarations shared through #include
.cpp C++ Source code; the most common spelling, and Visual Studio’s default
.cc C++ Source code; common in Unix projects and Google’s code
.cxx C++ Source code; an older alternative spelling
.hpp C++ header Headers meant only for C++, often full of templates
.hh C++ header The header partner of .cc
.hxx C++ header The header partner of .cxx
.m Objective-C Source for Apple apps (MATLAB scripts use .m too)
.mm Objective-C++ Files that mix Objective-C and C++

Plenty of C++ projects still use plain .h for their headers, so a .h file alone doesn’t tell you which language you’re looking at.

How to open a .c file with Folders

On Android

  1. Get Folders from the download section and install it (Android 7.0 or newer).
  2. Open it and tap Allow access. Android then asks for All files access, which lets Folders see your Downloads and other folders.
  3. Go to the folder with the file, or type part of its name in the search box.
  4. Tap the file. A .c, .h, .cpp or any other file from the table opens in the text editor.

If the file arrived in an email or a chat, tap it there and pick Open with → Folders. If a whole project came as a ZIP, open the ZIP in Folders and tap a file inside it, without extracting everything first.

On Windows and Linux

  1. Install Folders: the setup program on Windows, or a deb, rpm, AppImage, Flatpak, Snap or tar.gz package on Linux.
  2. Browse to the source folder in Folders and double-click the file.
  3. On Windows, the installer also adds Folders to File Explorer’s Open with menu for these types, so you can right-click a file there and choose Open with → Folders.

What you can do with it in Folders

  • Read it with syntax highlighting. Keywords, strings, numbers and both kinds of comment (// and /* */) are coloured, which makes long functions easier to follow.
  • Jump to a compiler error. GCC reports problems as main.c:42:13: error: .... Open Go to line, type 42, and you’re there. Document info shows the line and column under the cursor, the encoding (such as UTF-8) and the line endings.
  • Keep the header and the code side by side. The editor has tabs, so list.h and list.c can both stay open while you switch between the declaration and the code behind it.
  • Search. Find locates every use of a function. Find and replace, with Match case, replaces one match at a time or all of them, so you can change count and leave Count alone.
  • Make a quick fix. Edit the text, with undo and redo, and tap Save. Word wrap and smaller or larger text help on a phone screen, and Open in hex viewer shows the raw bytes if a compiler complains about a stray character.

Folders is a reader and a quick editor, not an IDE. It doesn’t compile or run code, suggest completions or jump to a function’s definition.

Other ways to open .c files

  • Visual Studio Code (free, Windows and Linux) with Microsoft’s C/C++ extension.
  • Visual Studio Community (free, Windows), where most Windows C++ projects are built.
  • Any plain text editor: Notepad on Windows, gedit or Kate on Linux.
  • To build the code: GCC or Clang on Linux, MSVC or MinGW on Windows. On Android, the Termux app can install Clang.

Problems opening a .c file?

  • A .m file looks strange. It may be a MATLAB script rather than Objective-C. It still opens as text, but MATLAB’s % comments won’t be coloured as comments.
  • Accented letters in comments show as odd symbols. Older Windows code is often saved in Windows-1252 rather than UTF-8. Check Document info to see which encoding Folders found.
  • You got a compiled file, not source. .o, .obj, .exe and .so files are machine code. The hex viewer will show their bytes, but there’s no source code inside to read.

Questions people ask

Can I open a .c file on Android? Yes. It’s a text file, and Folders opens it with highlighting and line numbers. You can read and edit it, but not compile it.

How do I run a .c file? You compile it first, for example gcc main.c -o main, then run the result with ./main. Opening the file only shows the code.

.c vs .cpp: what’s the difference? .c is C and .cpp is C++. Most C code also compiles as C++, but not all of it, so compilers use the extension to decide which language rules to apply.

What is a .h file, and can I open it on its own? It’s a header: declarations that other files include. It opens fine on its own, but it isn’t a program by itself.

Building with a Makefile or CMake? See how to open Makefile, CMake and Dockerfile files, or read about C# and Visual Studio project files. Folders opens many more formats too: see all 382 file types Folders opens.

Keep reading