PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

C

C

C is a programming language created in 1972 by Dennis Ritchie.

C (, as in the letter c) is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, including operating systems, as well as various application software for computers ranging from supercomputers to embedded systems. C was originally developed by Dennis Ritchie between 1969 and 1973 at Bell Labs, and used to re-implement the Unix operating system. Read more on Wikipedia...

Try now: Riju ยท Replit

#3on PLDB 50Years Old 3.8mUsers

Example code from Riju:

#include <stdio.h> int main() { printf("Hello, world!\n"); return 0; }

Example code from hello-world:

#include <stdio.h> main() { printf("Hello World\n"); }

Example code from Linguist:

#ifndef HELLO_H #define HELLO_H void hello(); #endif

Example code from Wikipedia:

#include <stdio.h> int main(void) { printf("hello, world\n"); }

Keywords in C

auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while

Language features

Feature Supported Example Token
Conditionals โœ“
Switch Statements โœ“
Constants โœ“
While Loops โœ“
Case Sensitivity โœ“
Assignment โœ“ =
Print() Debugging โœ“ printf
MultiLine Comments โœ“
/* A comment
*/
/* */
Line Comments โœ“
// A comment
//
Increment and decrement operators โœ“
Variadic Functions โœ“
double average(int count, ...)
{
 //
}
Manual Memory Management โœ“
#include 
#include 
int main(void)
{
  int *poin = malloc(4);
  free(poin);
}
Macros โœ“
https://gcc.gnu.org/onlinedocs/cpp/Macro-Arguments.html
Integers โœ“
int c = 10;
File Imports โœ“
//  If a header file is included within <>, the preprocessor will search a predetermined directory path to locate the header file. If the header file is enclosed in "", the preprocessor will look for the header file in the same directory as the source file.
#include 
#include "stdio.h"
Type Casting โœ“
double da = 3.3;
double db = 3.3;
double dc = 3.4;
int result = (int)da + (int)db + (int)dc; //result == 9
Directives โœ“
#include 
#define height 10
#ifdef
#endif
#if
#else
#ifndef
#undef
#pragma
Gotos โœ“
// C/C++ program to check if a number is 
// even or not using goto statement 
#include  
using namespace std; 
  
// function to check even or not 
void checkEvenOrNot(int num) 
{ 
    if (num % 2 == 0) 
        goto even; // jump to even 
    else
        goto odd; // jump to odd 
  
even: 
    cout << num << " is evenn"; 
    return; // return if even 
odd: 
    cout << num << " is oddn"; 
} 
  
// Driver program to test above function 
int main() 
{ 
    int num = 26; 
    checkEvenOrNot(num); 
    return 0; 
}
Structs โœ“
struct account {
  int account_number;
  char *first_name;
  char *last_name;
  float balance;
};
Comments โœ“
/* hello world */
// hi
Symbol Tables โœ“
// Declare an external function
extern double bar(double x);

// Define a public function
double foo(int count)
{
    double  sum = 0.0;

    // Sum all the values bar(1) to bar(count)
    for (int i = 1;  i <= count;  i++)
        sum += bar((double) i);
    return sum;
}
// Symbol Table:
// Symbol name|Type|Scope
// bar|function, double|extern
// x|double|function parameter
// foo|function, double|global
// count|int|function parameter
// sum|double|block local
// i|int|for-loop statement
Bitwise Operators โœ“
int i = 4; /* bit pattern equivalent is binary 100 */
int j = i << 2; /* makes it binary 10000, which multiplies the original number by 4 i.e. 16 */
Assert Statements โœ“
#include 
int i, a[10];
for (i = 0; i < 10; ++i)
  {
  assert(0 <= i && i < 10);
  a[i] = 10-i;
  }
for (i = 0; i < 10; ++i)
  {
  assert(0 <= i && i < 10);
  assert(0 <= a[i] && a[i] < 10);
  a[a[i]] = a[i];
  }
Strings โœ“
"hello world"
Pointers โœ“
int *ptr;
Booleans โœ“
Semantic Indentation ฯด
Operator Overloading ฯด
Garbage Collection ฯด
Regular Expression Syntax Sugar ฯด

Trending C repos on GitHub

repo stars description
Undecimus 4836 unc0ver jailbreak for iOS 11.0 - 12.4
LiteOS 3361 code and manual
git 29183 Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
nginx 9590 "An official read-only mirror of http://hg.nginx.org/nginx/ which is updated hourly. Pull requests on GitHub cannot be accepted and will be automatically closed. The proper way to submit changes to nginx is via the nginx development mailing list see http://nginx.org/en/docs/contributing_changes.html"
lvgl 2274 "Powerful and easy-to-use embedded GUI with many widgets advanced visual effects (opacity antialiasing animations) and low memory requirements (16K RAM 64K Flash)."
scrcpy 18275 Display and control your Android device
open-gpu-doc 734 Documentation of NVIDIA chip/hardware interfaces
betaflight 3001 Open Source Flight Controller Firmware
stb 10557 stb single-file public domain libraries for C/C++
src 1202 Public git conversion mirror of OpenBSD's official CVS src repository. Pull requests not accepted - send diffs to the tech@ mailing list.
littlefs 1480 A little fail-safe filesystem designed for microcontrollers
nmap 3319 Nmap - the Network Mapper. Github mirror of official SVN repository.
rt-thread 3199 RT-Thread is an open source IoT operating system from China.
navicat-keygen 7512 A keygen for Navicat
linux 79929 Linux kernel source tree
zephyr 2423 "Primary Git Repository for the Zephyr Project. Zephyr is a new generation scalable optimized secure RTOS for multiple hardware architectures."
klipper 1531 Klipper is a 3d-printer firmware
Dinossauro-Google 297 Cรณdigo do projeto onde uma rede neural aprende a jogar o dinossauro do google
openpilot 12310 open source driving agent
qmk_firmware 4961 Open-source keyboard firmware for Atmel AVR and Arm USB families
os-tutorial 16163 How to create an OS from scratch
xv6-public 2956 xv6 OS
php-src 24746 The PHP Interpreter
micropython 9015 MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Arduino 9944 ESP8266 core for Arduino

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements ยท Email ยท GitHub