.c File Extension
.c file contains, how to open and compile C source code, how Poly supports it, and how it differs from headers and C++ source. File extension details for .c
Full Support| File type | C source code |
|---|---|
| MIME type | |
| Encoding | Plain text, commonly UTF-8 or another ASCII-compatible encoding |
| Operating systems | Windows, macOS, Linux |
| Opens with | Visual Studio Code, Visual Studio, Xcode, Vim |
| Poly support | Yes. Poly recognizes .c as readable C source code. |
| Indexed by Poly | Yes. Poly indexes readable source for exact and semantic search. |
| Preview in Poly | Yes. C source opens in Poly's code editor with syntax highlighting. |
| Poly agent | Yes. The Poly agent can read and reason about the source text. |
What kind of file is a .c?
A .c file normally contains source code written in the C programming language. It is human-readable text, not a compiled program. Functions, declarations, preprocessor directives such as #include, and comments can all appear in it. Larger programs commonly split implementation across several .c files and place shared declarations in .h headers.
Compilers use the suffix as a language hint. GCC treats file.c as C source that must be preprocessed, while Microsoft C/C++ treats .c as C and .cpp as C++ by default.12 The source has no fixed magic bytes, so a filename, declared type, or source inspection is needed to identify it.
There is no dedicated IANA-registered media type for C source. Systems may use text/plain or an unregistered type such as text/x-csrc or text/x-c. GNOME's source-view definition recognizes both names and the *.c pattern.3 Poly treats the .c convention as readable text/plain.
program.cpp to program.c does not translate C++ into C. It can instead make a compiler parse the same text under different language rules.How do I open a .c on my computer?
Any text editor can open a .c file. A source editor such as Visual Studio Code, Visual Studio, Xcode, Vim, or Emacs adds C syntax highlighting and project navigation. Apple identifies C source as the public.c-source uniform type, and Xcode opens source files in its source editor.4
Opening source for reading does not execute it. To turn it into a program, use a C compiler and the project's build instructions. For a simple single-file example:
cc hello.c -o hello
Real projects may require headers, libraries, generated files, a particular C standard, and a build tool such as Make or CMake. Do not compile or run untrusted source outside an appropriately isolated environment.
Poly support for .c
Poly opens .c files in a read-only, code-friendly viewer with C syntax highlighting, word wrap, and in-file search. It indexes readable source for exact and semantic search, so you can find a symbol by name or locate code by what it does. The Poly agent can read the source to explain functions, summarize logic, or help trace likely behavior.
Poly does not compile or execute the program, resolve included headers, or reproduce a project's build environment. Keep related headers, build files, and documentation together when you want search or the agent to understand the wider project.
History of .c
Dennis Ritchie developed C from B at Bell Labs during 1971 to 1973, alongside early Unix. By early 1973, the language was mature enough for the Unix kernel to be rewritten in C on the PDP-11.5 The compact .c suffix became the conventional marker for a C translation unit.
C later moved from book-based practice into formal standardization. The current ISO/IEC 9899 edition, commonly called C23, was adopted in 2024.6 Old and new .c files can target different dialects, extensions, platforms, and libraries, so the suffix alone does not establish compatibility.
Working with .c and alternatives
Choose the related file type that matches the stage of work:
| File | Typical role |
|---|---|
.c | C implementation source, normally preprocessed and compiled |
.h | Declarations and macros shared by C or C++ source |
.i | C source after preprocessing |
.o or .obj | Compiled object code, not readable source |
.wasm | Portable WebAssembly binary produced by a compatible toolchain |
Keep source in version control and preserve the build configuration that selects the compiler, target, language edition, warnings, and linked libraries. A compiler can produce object code, an executable, assembly, or preprocessed output from .c; those are build products rather than interchangeable renamings.1
Footnotes
- GNU Project. Options Controlling the Kind of Output. GCC documents
.cas C source that must be preprocessed and describes compilation stages and outputs. ↩ ↩2 - Microsoft. Compile a C Program on the Command Line. MSVC uses
.cfor C source by default. ↩ - GNOME. GtkSourceView Language Definition Tutorial. The C example associates
*.cwithtext/x-candtext/x-csrc. ↩ - Apple. C Source Uniform Type and Editing Source Files in Xcode. ↩
- Dennis M. Ritchie. The Development of the C Language. Bell Labs. ↩
- ISO/IEC JTC 1/SC 22/WG 14. C Language Working Group. WG14 identifies C23 as the current ISO/IEC 9899 edition. ↩