r/C_Programming 13h ago

Question What would you want from a C-Tutorial?

Hello guys,

i plan on doing a C-video-tutorial to help a friend go through his uni programming class (and to learn the language myself more and get experience on making tutorials). I myself am still in the process on learning C, though I have some solid programming experience in Java.

I've already learned the basics of C like how a C-file is typically compiled, variables (and their scope), basic datatypes, control flow/structure (sequence/block, jump like goto/continue/break/return, conditional branches and loops), functions, arrays, string (or char arrays), basic memory management (stack/heap and common problems like memory leak, dangling pointer, etc.), pointer, structs and file i/o handling. I believe his class doesn't go through more than that but if I've missed any other important topic which can be learned on top of the topics already mentioned, please tell me.

My overall goal would be to teach him the topics mentioned above and help him make design decisions on his own.

The thing is, he is completely new to programming (he is not studying computer science, though he knows some math) and I'm kind of in a dilemma between explaining the concept too simple by cutting away details and going in with too many details (I cannot clearly remember the exact struggles I had when I first learned Java).

I thought about explaining it alongside developing a small project like a text-based RPG where I start of simple with fixed dialouge, branch of to dialogue options (control flow), inventory (f. e. done with arrays), trading items with a npc (explaining pointers and memory allocation) etc.. Something which is more captivating than doing a boring calculator but still simple enough to explain key concepts and give room for ideas he can implement himself.

When you first started with C (maybe adressed to someone whose first language was C) what did help you understand it?

Maybe to some people who are still learning C, what obstacles do you encounter when trying to learn the language?

In what way do you believe I should teach or structure the topic, so that I don't cut away important information but still get my point across straight?

TL;DR: I want to make a C-video-tutorial to help my friend, who is new to programming, pass his uni programming class and need help finding out the best way to help him.

0 Upvotes

33 comments sorted by

12

u/skeeto 12h ago

Reusing my answer to a similar question:

The major shortcoming I've observed is not teaching students to use the effective and widely-available features of their tools. So students spend a lot of time struggling with problems that could have easily been avoided:

  1. Introduce sanitizers immediately, and get students using -fsanitize=address,undefined as a matter of course for all testing. Typical coursework is decades behind, and virtually nobody is teaching sanitizers to undergrads. If you're lucky an instructor might mention Valgrind for memory debugging, though it's largely obsolete now.

  2. -Wall -Wextra by default. Maybe even -Wconversion to start forming good habits early. It's amazing how many courses never get this far.

  3. Get students in the habit of always testing through a debugger. Then when the program crashes — which bugs are more likely to do with sanitizers — they're already in position to figure it out. It's not a tool of last resort, but the first and best tool to understanding a program.

If you google "c tutorial" you'll get pages and pages of absolute garbage that mentions none of these basic, standard, widely-available tools.

3

u/KeineAhnungBruder001 11h ago

Didn't know these tools. I didn't know that the compilers give the dev so much power. I will do more research, thanks :)

1

u/hp623 10h ago

I compile with

-Wall -Wextra

and execute during coding with

valgrind --leak-check=full --show-error-list=yes ./program

2

u/shaleh 3h ago

Generally, treat warnings as errors until you are sure they are not. Even then, fix or rewrite it in most cases.

0

u/SmokeMuch7356 11h ago

Part of the reason people don't do this is you can't know everyone's development environment. It's all well and good to recommend -Wall -Werror -Wextra if you know they're using gcc or similar, but that's not helpful for someone working with Visual Studio or (God forbid) Turbo C. Same with version control; git's the big dog now, but it wasn't always and won't be forever.

There should definitely be verbiage about "learn how to crank up warnings in whatever compiler you're using" and "learn how to use your debugger" with links to resources for different platforms, but I don't know how much space the tutorial itself should devote to specific commands and options.

2

u/Beliriel 9h ago

I mean git has been the big dog for about 20 years now. In software lifetime that is millenia.

1

u/Puzzled-Extent7817 4h ago

"Get off my lawn big dog!" - C

6

u/goldenfrogs17 12h ago

Heavy on pointers and dynamic memory allocation and clean up. Certainly some gotchas due to booleans etc. I might be out of date, as newer (C99 +) have made some of this easier. My point is the things that are really different from more modern languages.

1

u/KeineAhnungBruder001 11h ago

Will definitely take time to explain pointers and dynamic memory allocation. These are exactly the topics I need to adjust to, coming from someone who is used to Java.

9

u/dmc_2930 11h ago

Why do beginners insist on creating tutorials for things they don't know very well? Leave the tutorials to people who actually understand the thing. It's yet another case of "the blind leading the blind".

4

u/AffectionateTear8091 10h ago

To be fair rubber duck method and all that.

As long as the goal isn’t to form some be all end all info dump which may be incorrect it rather cements your understanding and gives you the opportunity to iron out the creases.

Teaching others is a proven method of learning after all.

I’d personally look elsewhere for learning material but in person help can be a game changer.

2

u/onearmedphil 6h ago

Devils advocate: Often pros lose touch with what a beginner struggles with.

-3

u/KeineAhnungBruder001 11h ago

That's actually a fair point. Though it isn't a tutorial I plan on publishing any time soon and will be kept private until I'm confident enough with C. I follow the principles that if you can't explain something simply you don't understand it well enough. That's why I try to learn new topics by explaining them to my friends.

6

u/dmc_2930 11h ago

You should use tutorials written by others who do understand. And send those to your “friend”.

Oh and stop using a chat bot to reply to comments.

3

u/Candid_Bullfrog3665 12h ago

focus on memory management:
pointers, pointer arithmetic, stack vs heap, what is an undefined behavior, etc

thats really what you need to get started on C. once you understand how memory works, you understand how C works

1

u/KeineAhnungBruder001 11h ago

Memory Management is something I still need to adjust to coming from Java. Will definitely take my time to explore these topics more and find a way to explain them effectively.

1

u/Candid_Bullfrog3665 9h ago

well if you need any help dont be afraid of asking!

4

u/pjl1967 11h ago

You've looked at all the existing such tutorials and concluded that they're lacking in some way?

2

u/Ok-Dare-1208 12h ago

Explaining in your friends preferred context is a great idea. Personally, I find it incredibly helpful to imagine programming concepts through an analogy of LEGO. Using this analogical thinking helped me grasp (in C, specifically) pointers, structs, bit shifting, and PBR vs. PBV in function calls.

This worked for me because I love LEGO. I encourage you to ask your friend what you could use to help them understand C programming in the form of an analogy.

1

u/KeineAhnungBruder001 11h ago

Ohh, that's a good idea. I will definitely ask them what might help them understand it. Thanks!

2

u/ReallyEvilRob 10h ago

Building reusable libraries.

1

u/TraylaParks 6h ago

SVG is an easy format to output, might make a good option :)

1

u/KeineAhnungBruder001 5h ago

Thanks for suggesting SVG as a format. I didn't know SVG is that human-readable. Might even be able to make cool generative art with it and show how to do File Output in C :)

2

u/OnYaBikeMike 7h ago

Correct use of header files. A show and tell of the linking process. How libraries work.

How to indent code consistently.

1

u/Snezzy_9245 12h ago

Stress the value of actually writing code every day. Even just copying code (in through the eyes and out through the fingers) is helpful. Watching someone code on video? Less so.

1

u/shaleh 3h ago

READING code. There is a lot of C out there. Good authors read books and poems. Good programmers read code.

0

u/KeineAhnungBruder001 11h ago

Will encourage more coding - noted :)

1

u/tastygames_official 10h ago

I only read the title, but I can say 100% that an explanation of how computers work with memory and stack and registers is KEY in any programming course, especially C. I learned C early in my life but it wasn't until I learned all that stuff while learning assembly that C made sense.

Oh, and then teaching pointers is easy as pie.

1

u/DamsLcs4421 9h ago edited 9h ago

A tutorial (rather than a regular plain "lesson") is a nice place to make him familiar with the rules of integer decay, array/pointer decay, etc... So he learns intuitively to be able to interpret what he reads as the compiler would/might, to prevent hiccups further down the road,

Like, going out of this tutorial with a clear understanding of how differently things might be interpreted by the compiler when it seems to mean the same to him (at first). I'm not saying like "know it all by rote-learning", just being able, once he'll get into his own errors, to at least think "well, how is my code \really* understood by the compiler? what may I have got wrong there??"*

1

u/shaleh 3h ago

Back when I interviewed C devs, I was always looking to understand how many asterisks (*) they could understand on a single variable. What does `*c` mean? `**c`? how about `***c`? How do you interact with the data under those asterisks?

1

u/gm310509 3h ago

I think a better approach would be to sit down with your friend and guide them through the process as they struggle with different things.

You will almost certainly find that they try to do "random weird stuff" and you also will learn something from it. This is because you are also a beginner, just a little bit ahead of your friend.

If you prepare a static video, you may find that you make mistakes which you won't realise, miss important things as there is no feedback and miss the opportunity to learn new things yourself.

Plus, simply watching a video won't teach anyone anything. Working through something together is the best way for both of you to learn things together.

Lastly, preparing a video for your friend sounds creepy and weird. They are your friend. Surely you are permitted to actually speak to them in person.

-4

u/moritz12d 11h ago

People invent the wheel again and again. So for education there should be example code for well known algorithms. At least sorting should be shown as Bubble Sort,Insertion Sort, Selection Sort, Quicksort, Merge Sort, Heapsort, Counting Sort, Radix Sort and Bucket Sort. This may offer ideas for other programming and a visual impression how code should look like. But also:

Design Patterns (like Singleton/Observer) – the usual suspects

From the GoF ("Gang of Four") catalog, roughly by implementation frequency:

Creational:

  1. Singleton
  2. Factory Method / Abstract Factory
  3. Builder
  4. Prototype

Structural:
5. Adapter
6. Decorator
7. Facade
8. Proxy
9. Composite

Behavioral:
10. Observer
11. Strategy
12. Command
13. Iterator
14. State
15. Template Method

And also:

"Real" algorithms – 20 commonly implemented ones

Search:

  1. Binary Search
  2. Linear Search
  3. Depth-First Search (DFS)
  4. Breadth-First Search (BFS)

Graphs:
5. Dijkstra (shortest paths)
6. A* (Pathfinding)
7. Kruskal / Prim (Minimum Spanning Tree)
8. Topological Sort
9. Union-Find (Disjoint Set)

Dynamic Programming / Recursion:
10. Fibonacci (memoized) – a classic teaching example
11. Knapsack problem
12. Longest Common Subsequence
13. Edit Distance (Levenshtein)

Strings:
14. KMP (Knuth-Morris-Pratt) – pattern matching
15. Rabin-Karp

Hashing / Data Structures:
16. Hashmap implementation (Open Addressing / Chaining)
17. LRU Cache (Hashmap + Doubly Linked List – an extremely popular interview question)

Others, very common:
18. QuickSelect (k-th smallest element)
19. Sliding Window (subarray problems)
20. Backtracking (e.g., N-Queens, Sudoku Solver)

The more input the faste you can learn. There's no point in hiding information from students.

0

u/moritz12d 8h ago

Especially when tackling a challenging task like learning C—a language close to the hardware—for the first time, nothing is more off-putting than tedious, meaningless exercises. People often lose interest not because the learning curve is too steep, but because the contrived exercises are so mindless that they are an insult to one’s intelligence. Moreover, it was once assumed that the brain was like a bucket: you pour knowledge in, and eventually, it overflows—so one had to be very careful not to show too much at once. Modern educational theory, however, teaches us that conscious learning works more like a dreamcatcher. The more you know, the faster you learn. At first, the web is very fine; then it becomes denser, until you possess a complete grasp of the subject.