Dr. Roger Ianjamasimanana

C programming tutorials

These tutorials include a series of step-by-step lessons that will help you become proficient in C programming. You’ll learn topics like variables, loops, functions, and memory management through practical examples and hands-on exercises.

By Roger Ianjamasimanana

The stdbool.h header provides support for boolean data types in C by introducing bool, true, and false to simplify logical checks, reduce confusion from integer-based logic, and enhance readability. These expressions are stored in the built-in _Bool type in stdbool.h.

By Roger Ianjamasimanana

The stdarg.h header defines macros for handling functions with a variable number of arguments. A va_list data type is used to track them, and va_start initializes the list. va_arg retrieves arguments in sequence by type, and va_end cleans up when finished. It is widely used in logging, debugging, or building functions like printf and other distinct custom routines.

By Roger Ianjamasimanana

The signal.h header in C defines mechanisms for capturing and handling asynchronous signals like SIGINT or SIGSEGV. Using signal() lets you set custom or default handlers, while raise() sends signals to the current process. The sig_atomic_t helps manage shared data safely in handlers, preventing inconsistent states due to concurrent updates. It defines constants SIG_IGN and SIG_DFL.

By Roger Ianjamasimanana

The macro setjmp and the longjmp function enable a direct jump across nested function calls, seamlessly bypassing the usual call-return flow. The setjmp macro saves the current environment and address in a jmp_buf, returning zero initially. the longjmp function restores that state from anywhere in the program, returning a chosen nonzero value from setjmp, enabling structured error handling or abrupt escapes.

By Roger Ianjamasimanana

The math.h in the C standard library offers useful functions for trigonometry, exponentials, logarithms, power computations, and rounding. Examples include sin, cos, exp, pow, sqrt, and log. It also handles special values like infinity and NaN, and provides classification macros (isinf, isnan) and constants (HUGE_VAL) to facilitate error checking and robust calculations in programs. This articles list all the available math.h functions in C and gives examples of how to use them.

By Roger Ianjamasimanana

The locale.h in C Library enables adjusting language and regional settings for data formatting, currency, time, and collation. By providing macros (e.g., LC_CTYPE, LC_TIME) and functions like setlocale and localeconv, it tailors applications to cultural norms, improving numeric, monetary, and string handling for localized, internationally-friendly software experiences and fosters effective i18n compliance.

By Roger Ianjamasimanana

In C, limits.h is a header file that defines macros representing the limits of integral types on your system. By using these macros, you can write portable and robust code that adapts to various compilers and architectures. This article takes an in-depth look at all the macros defined in limits.h, along with detailed explanations and usage examples.

By Roger Ianjamasimanana

The float.h header in C defines macros that describe the floating-point environment, including the maximum and minimum representable values, decimal digits of precision, and epsilon for each floating-point type. By referencing these macros, developers can write portable code that adapts to varying hardware capabilities, ensuring precise, reliable, and consistent floating-point computations in diverse usage scenarios.

By Roger Ianjamasimanana

The errno.h header is part of the standard library and provides the errno global variable and a range of predefined error macros to help detect and respond to system-level or library function errors. This article gives a detailed overview of the errno.h header in C for better error management.

By Roger Ianjamasimanana

The ctype.h header provides a set of functions for testing and manipulating characters. They allow programmer to check if a character is alphabetic, numeric, uppercase, lowercase, or a control character, among others. You can also convert characters to uppercase or lowercase. This makes ctype.h indispensable for parsing text, handling user input, or performing any kind of character-level checks.

By Roger Ianjamasimanana

In C programming, the assert.h header provides an essential debugging tool through the assert macro. This macro verifies assumptions you make about your code and halts program execution if those assumptions fail. While it’s often used during development and testing, the assert macro can also be selectively enabled or disabled in production builds. This article explains how to use assert.h in C.

Editor’s corner

ID photo of Dr. Roger Ianjamasimanana

Welcome to my personal website! My name is Roger Ianjamasimanana. I have a PhD in Astronomy, and I love programming. Here, I share educational content on Astronomy, programming languages, and Linux. I created this blog not only as a personal reference for myself but also with the hope that the resources and insights I share here might benefit others.

Disclaimer

Dr. Roger Ianjamasimanana’s ID photo

The information provided on this blog is for educational and informational purposes only. While I strive to ensure accuracy, I make no warranties regarding the completeness or reliability of the content. Use of any information is solely at your own risk. I am not liable for any actions taken based on the content of this blog.