Git Product home page Git Product logo

helloworld.c's Introduction

Hello, World! - C

The C Programming Language logo

C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, and protocol stacks, but its use in application software has been decreasing. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.

C (programming language) - Wikipedia

Hello, World in C

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}

Compile and Run

  • gcc is the GNU Compiler Collection, which can compile C, C++, Objective-C, Fortran, and Ada.

    to compile a C program:

    gcc -o hello hello.c
  • g++ has additional behaviours in it specific to c++, such that it can compile and link a c++ program out of the box to compile a C program:

    g++ -o hello hello.c
  • llvm is a collection of modular and reusable compiler and toolchain technologies.

    to compile a C program:

    llvm-gcc -o hello hello.c
  • clang is a C, C++, and Objective-C compiler which encompasses preprocessing, parsing, optimization, code generation, assembly, and linking.

    to compile a C program:

    clang -o hello hello.c

How C compiler works?

Compilation process in C involves four steps:

graph LR;
    subgraph Linking
        D1["Object code (.o)"] --> D2["Linker"];
        D2 --> D3["Executable file"];
    end
    subgraph Assembling
        C1["Assembly code (.s)"] --> C2["Assembler"];
        C2 --> C3["Object code (.o)"];
    end
    subgraph Compiling
        B1["Modified source code (.i)"] --> B2["Compiler"];
        B2 --> B3["Assembly code (.s)"];
    end
    subgraph Preprocessing
        A1["Source code (.c)"] --> A2["Preprocessor"];
        A2 --> A3["Modified source code (.i)"];
    end
    
    A3 --> B1;
    B3 --> C1;
    C3 --> D1;
Loading
  1. Preprocessing: The preprocessor takes the source code and eliminates comments, expands macros, and includes header files. The output of this step is a .i file.

  2. Compiling: The compiler takes the preprocessed file and converts it into an assembly code file. The output of this step is a .s file.

  3. Assembling: The assembler takes the assembly code file and converts it into an object code file. The output of this step is a .o file.

  4. Linking: The linker takes the object code file and links it with other object code files and libraries to create an executable file.

helloworld.c's People

Contributors

appleboiy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.