Programming Exercise 3.4 from Modern C Programming Methods, 2nd Edition

Programming Exercise 3.4 from Modern C Programming Methods, 2nd Edition Programming Exercise 3.4 #include int main() { printf(“Enter phone number[(xxx) xxx-xxxx]:”); int num1,num2,num3; /* Use num+number to represent the three segments of the phone number */ scanf(“(%d) %d-%d”,&num1,&num2,&num3); printf(“You entered %.3d.%.3d.%.4d\n”,num1,num2,num3); /* %.3d,%.4d indicates the integer with a specified width, and leading zeros will be … Read more

Analysis of C Variable Argument Functions (va_start, va_end, va_list…)

PS: Please indicate the source when reprinting, all rights reserved.PS: This is just based on my own understanding,if it conflicts with your principles and ideas, please forgive me, do not criticize. Environment Description   None Introduction   A few years ago, out of interest, I researched the issue of variable arguments in C. At that time, I … Read more

The Wonderful Uses of sprintf() and sscanf() in C++

When writing code, we often encounter type conversion, which can be quite troublesome. However, today I discovered a very interesting function while reviewing solutions: sprintf and sscanf. (These can also be used in C language.)You will notice that the names of these two functions are quite similar to printf and scanf. The sprintf function prints … Read more

Linux-Insides: Unlocking the World of Kernel Development, Step by Step into the Depths of Linux

What is Linux-Insides? In simple terms, Linux-Insides is a “living note” that dissects the internal implementation of the Linux kernel. It is not a rigid document like the official manuals, but a series of articles written by the author 0xAX based on his own learning notes, complete with source code analysis, illustrations, assembly mini-experiments, and … Read more

State Machines: The ‘Traffic Commander’ of the Embedded World

State Machines: The 'Traffic Commander' of the Embedded World

Click the blue text above to follow us Dear programmers, today we are going to talk about the superstar of embedded systems – the state machine! It acts like a traffic commander, organizing the chaotic behavior of your system into a well-structured manner. Imagine this: your smartwatch is usually “asleep” (low power state), and with … Read more

Writing the Simplest Linux Kernel Driver (Hello World)

Writing the Simplest Linux Kernel Driver (Hello World)

Table of Contents 1. Introduction 2. Overall Process 3. Position in the System 4. Writing C Source Code 5. Writing Makefile 6. Compile, Load, View, Unload 6.1 Compile Module 6.2 Load Module 6.3 View Module and Logs 6.4 Unload Module 6.5 View Logs Again 7. Common Errors and Troubleshooting 7.1 insmod Error: invalid module format … Read more

In-Depth Analysis of ‘Unconventional’ Values in C: Infinity and NaN

In-Depth Analysis of 'Unconventional' Values in C: Infinity and NaN

As we explore the fascinating world of C programming, we typically deal with common values such as integers and floating-point numbers. But did you know that C also hides some ‘unconventional’ values that represent extreme cases in the computing world—such as ‘Infinity’ and ‘Not a Number’ (NaN)? Today, we will delve into these special floating-point … Read more

Embedded Interview Questions from a Major Company – Implementing Stack and Queue Containers in C

Embedded Interview Questions from a Major Company - Implementing Stack and Queue Containers in C

Today, I had an interview with a major company, where I was asked how to implement stack and queue using C language. I found the questions quite interesting, so I would like to review them here.StackA stack is a last-in-first-out (LIFO) data structure. The implementation idea is to use an array to realize it, maintaining … Read more

Essential Interview Questions for Embedded C Development: What is the Difference Between Const and Volatile?

Essential Interview Questions for Embedded C Development: What is the Difference Between Const and Volatile?

In this article, we will explore the qualifiers in C programming (const and volatile). This is a very important topic in C and embedded systems. In interviews, this is often the first question about the C language. What is the volatile keyword? Why use volatile? What is the difference between const and volatile? What are … Read more

C Language Programming Notes – Usage of printf

C Language Programming Notes - Usage of printf

Example 1: Programming to output a triangle. Can you try to output this shape using multiple methods?(1) Source code #include <stdio.h> #include <stdlib.h> int main(){ printf("*\n"); printf("**\n"); printf("***\n"); printf("****\n"); return 0;} (2) Running effect imageExample 2: Programming to calculate the results of addition, subtraction, multiplication, and division of two numbers.(1) Source code #include <stdio.h> #include … Read more