.C
C source code
Introduction
A .c file holds a program written in the C programming language, as
plain text. A compiler turns each .c file into an object file, and a
linker joins those into a program or library.
A .h file is a header: declarations of functions, types and constants
that several .c files share by including it. C++ and Objective-C also use
.h headers. On systems where file names are case sensitive, a capital
.C usually means C++ rather than C.
Software
- GCC (Linux, Windows, macOS)
- Clang (Linux, Windows, macOS)
- Visual Studio (Windows)
- Visual Studio Code (Windows, macOS, Linux)
- CLion (Windows, macOS, Linux)
- Xcode (macOS)
- Vim (Windows, macOS, Linux)
Structure
A C source file is plain text, today usually UTF-8 or plain ASCII, with no header or
signature. Before compiling, the preprocessor handles the lines that start with
#: #include pastes in a header, #define makes a
macro, and #if keeps or drops blocks of text. What remains is a series of
declarations and function definitions, one of which is usually main.
#include <stdio.h>
int main(void)
{
printf("Hello, world\n");
return 0;
}