What Is a C File?

How to open, edit, and convert C files

What to Know

  • A C file is a plain text C/C++ source code file.
  • Open one with any text editor, or a program like Eclipse.
  • Convert to other text formats with those same programs.

This article describes what a C file is, how to open one, and how to convert one to a different file format.

What Is a C File?

A file with the .C file extension is a plain text C/C++ source code file. It can both hold an entire program's source code in the C or C++ programming language, and be referenced by other files from within a C project.

Note that some programs use a lowercase c file extension to denote a C source code file, and an uppercase C for C++, but that's not required. CPP is used for C++ source code files, too.

If the file isn't in the C or C++ programming language, it might instead be a Lite-C script file written in lite-C, a similar programming language as C/C++.

Both of these file types are related to applications that are used to build software programs and video games.

CFile also refers to Microsoft Foundation Class file classes, but this doesn't have anything to do with the source code file formats explained here.

How to Open a C File

Any text editor like Notepad++, Emacs, the Windows Notepad program, EditPlus, TextMate, and others, can open and view a C file if it's a C/C++ source code file.

These programs are useful because they're generally lightweight when compared to full application developers like the ones listed below. Plus, most of them support syntax highlighting, which is usually preferred since it makes editing and sifting through the source code much easier.

However, C files are usually opened within the context of a software development program like Visual Studio, Eclipse, C++Builder, Dev-C++, or Code::Blocks.

The lite-C program from Conitec Datasystems is the primary program used to work with Lite-C script files, but they might open with text editors, too.

How to Convert C Files

There are a number of conversions you can do related to C and C++ but those are out of the scope of this article. For example, you can use the programming language to convert to or from char array, integer, string, etc., but those do not apply to C files themselves, but rather to the functions that the files provide.

If that's what you're looking for, we recommend visiting some other resources like Stack Overflow.

However, if you're truly after a C file converter, you can use any text editor or one of the programs mentioned above, to convert or save the file to a different text-based format like TXT or HTML. They will most likely no longer be usable as source code files with Eclipse, Dev-C++, etc., though, so long as they exist in a different file format.

There are also a number of source code converters available from Tangible Software Solutions that can convert C++ to C#, Java, or VB. Keep in mind, however, that the free editions are limited when it comes to the number of lines that can be converted at one time.

Still Can't Open It?

Given that the C file extension is merely one letter, it's easy to mix it up with other file formats. This is the first thing you should look for if you can't get your file to open, because it's likely that you're not actually dealing with a C file.

For example, if you try viewing your file with a text editor because you assume it's a source code file, but can't read anything, you probably have something entirely different, like a CAB or CSH file.

CS is a very similar file extension, but it's used for Visual C# source code files and ColorSchemer Studio Color Scheme files. If you have a CS file, it might open just fine with the programs that support C files, since it's a similar format with content written in the C Sharp language. However, the latter file format is used specifically with ColorSchemer Studio and will not work in the same way as C Sharp or C files.

As you can see, those file formats, and many others, have the letter "C" in them, but that doesn't mean they are at all related to the formats explained on this page.

To make this even more confusing than it might already be, the CSH file extension is used not only as a non-text file with Adobe Photoshop (it's a Custom Shapes file) but also as a plain text C Shell script file, meaning that depending on what you have, it could very well open in a text editor (like with CS files), but that still doesn't mean it's a C/C++ source code file or even that it can be opened in every application listed above.

FAQ
  • How do I create a file in C?

    An easy way to create a C file is to use Notepad. Type your C code into a Notepad file and then save the file with the .c extension. Type the filename with quotes, such as "filename.c", so the file won't default to a .txt extension. Then, compile your program using a compiler such as Microsoft Visual Studio C/C++ Compiler.

  • How do I create a header file in C++?

    You can either import a pre-existing header file or create a user-defined header file. To create a header, write your C/C++ code and save it in a file with the .h extension. To import the header file, you'll use “#include”; the syntax would be #include <filename.h> or #include "filename.h".

Was this page helpful?