Using typedef – DEV Community

typedef is considered one of issues that I can by no means look again from. Primarily, it permits to alias current varieties in C and makes code a lot simpler to learn and write. Take the next instance for example. struct my_struct { int a; char b; } void init_my_struct(struct my_struct* s, int a, char […]

A World Without C – DEV Community

The Whitehouse released a report this week encouraging the usage of reminiscence protected languages, over non reminiscence protected languages, particularly calling out C/C++. This has clearly precipitated a stir within the programming neighborhood, particularly contemplating most individuals’s low opinion of the federal government’s skill to provide high quality software program. However should you’ve used a […]

Building A File Compressor Using C And Wasm

Checking Wasm Instruments For C In a previous article I did a small experiment with Go and Wasm to test the state of instruments obtainable for it in 2024. Throughout such endeavour I discover a instrument known as Emscripten that drawn my consideration and made my thoughts to do one experiment, now utilizing C. Emscripten […]

More About File Operations in C Including File Descriptors

Complete Information to File Operations and System Calls in C File operations and system calls are elementary points of programming in C, important for managing recordsdata, performing I/O operations, and interacting with the underlying working system. This complete information will stroll you thru creating, opening, closing, studying, and writing recordsdata, together with the next: File […]

Compound Literals in C – DEV Community

Introduction Amongst different issues, C99 added compound literals for arrays, structs, and unions. Simply as 42 specifies an int literal, a compound literal specifies a literal for an array, struct, or union. Contemplate: struct level { int x, y; }; typedef struct level point_t; void draw_circle( point_t middle, unsigned radius ); Enter fullscreen mode Exit […]

C Const Conundrum – DEV Community

Introduction Initially, const was not a part of C. (C++ added const and it was later back-ported to C89.) In C, there are two makes use of for const: const objects. Tips that could const. Neither is especially sophisticated. Nevertheless, constexpr was added in C23. Understanding which of the 2 to make use of in […]

typeof in C23 – DEV Community

Introduction Amongst different issues, C23 added the typeof and typeof_unqual key phrases that return the kind of an expression: int x; // int (clearly) typeof(x) y; // additionally int Enter fullscreen mode Exit fullscreen mode Be aware: for this text, I’ll merely use typeof to imply both typeof or typeof_unqual reasonably than at all times […]

“Is 2024 a Leap Year?”, Here’s how to check, using C language.

Introduction What’s a intercalary year?: A intercalary year is a 12 months that may be a day longer than different years, i.e. it has three hundred and sixty six days as a substitute of twelve months. When is the additional day?: In a intercalary year, the additional day is the twenty ninth of February, as […]

_Generic in C – DEV Community

Introduction Amongst different issues, C11 added the _Generic key phrase that permits compile-time collection of an expression based mostly on the kind of its argument. Personally, I feel _Generic is just too, properly, generic of a reputation. It ought to have been referred to as one thing like _Typeswitch. The motivating use-case is the flexibility […]

Unions in C

Introduction A union is syntactically identical to a struct and is used to retailer knowledge for any one of its members at any one time. For instance: union worth { lengthy i; double f; char c; char *s; }; union worth v; v.i = 42; // worth is now 42 v.c = ‘a’; // worth […]