《From ‘Segmentation Fault’ to the Stars: A Beginner’s Awakening Journey in C Language》
1. Getting Acquainted with C Language: The Awkward ‘Hello World’
#include <stdio.h> // I copied this line three times before getting it right
int main() {
printf(“Hello World”); // Why is it not print?
return 0; // Does anyone really check the return value?
}
Beginner’s Confusion:
● Staring blankly at the implicit declaration warning when compilation fails
● Shocked to find that the program still runs without return 0
● The sense of ceremony when seeing the .exe file for the first time
2. Pointers: The Key to Open Pandora’s Box
Cognitive Evolution:
1. Variables are storage cabinets → 2. & is the cabinet number → 3. * is the universal key to open other cabinets
int a = 42; // My first integer
int *p = &a; // So this is the legendary pointer
*p = 99; // The magical moment of modifying from a distance
Late Night Epiphany:
● Understanding scanf(“%d”, &a) felt like hearing gears mesh
● The worldview collapse when discovering that the array name is actually a pointer
● The joy of swapping variable values using pointers for the first time
3. Memory Management: The ‘Creator’ Privilege of Programmers
Shocking Moment:
int arr = malloc(10 * sizeof(int)); // The moment of claiming territory from the operating system
free(arr); // The thrill of holding the power of life and death
Lessons Learned:
● The guilt of memory leaks from forgetting to free
● The program crash when accessing freed memory
● The truth that wild pointers are more dangerous than wild dogs
4. Functions: Quantum Entanglement in the Universe of Code
Wonderful Experience:
void change(int x) { x = 100; } // Modifying the main universe variable in another dimension
int main() {
int num = 5;
change(&num); // This operation feels like tying knots on the timeline
printf(“%d”, num); // The magical reality of outputting 100
}
Revelations:
● The essence of function parameter passing is value copying
● The thrill of achieving ‘remote control’ using pointers
● Recursive functions are philosophically shocking like a Möbius strip
5. The Programming Force that C Language Taught Me
1. The Essence of Computers: Concrete understanding from registers to caches
2. Precision Thinking Training: Every byte deserves respect
3. Awakening Control Desire: Rejecting the ‘gentle trap’ of garbage collection
6. To Newbies Like Me
● Don’t be afraid of `warning: control reaches end of non-void function`
● Master the `printf debugging method` to perfection
● Remember that every segmentation fault is a stepping stone to understanding
Code Easter Egg: The Romance of a Beginner
// Sending a message to my past self three months ago
void send_message_to_past()
{
printf(“Don’t give up!\n”);
printf(“Pointer arrays and array pointers are really different!\n”);
printf(“You will soon understand that linked list that drove you crazy!\n”);
}
The charm of this article lies not in technical depth, but in the authentic portrayal of a beginner’s confusion, epiphanies, and growth. With specific code snippets, emotional descriptions, and humorous self-deprecation, readers can feel:
1. Every expert was once a novice
2. Programming errors are the best teachers
3. Understanding the essence of computers is more valuable than quick frameworks
In the days to come, I will continue to update small knowledge about C language, hoping everyone likes and saves it, so as not to miss important information.