N
N
Nemo1112020-11-30 23:14:07
C++ / C#
Nemo111, 2020-11-30 23:14:07

How to read C code faster and better?

Good afternoon. I am fond of the C language. I don't know him 200%. I write and read programs a little. I would like someone to share their experience, "how he learns C programs." I feel like I'm doing it slowly. Sometimes I get confused and quit. Are there any effective ways to read C programs, maybe you have some kind of your own algorithm? Or some good debugger...
I do this:
I look at the source structure, at the header files, at the Makefile.
some time I look at the contents of all files. (if the project is not quite simple, apathy already begins here).
I start reading from the point of entry into the program, jump through the functions, leave comments, because the further I go, the more I forget what happened before. (perhaps it is worth drawing some graphs for yourself?)
if it's not at all clear, I try to compile the program and use the debugger. (if everything is on macros, then I'm not trying to try it already).
I understand that perhaps I do not have enough perseverance, but still.
In general, are there any tips, useful books or courses. Maybe someone somehow draws graphs so as not to get confused?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GavriKos, 2020-11-30
@GavriKos

Maybe someone somehow draws graphs so as not to get confused?

These graphs are called UML diagrams. And yes, they can help. There are other types of diagrams, yes.
But I would never try to spin the program from the entry point. It seems more logical to me to proceed from some specific functionality and look for how it is implemented.

E
Egorithm, 2020-11-30
@EgoRusMarch

No way. Read and think. There is no formula for happiness. Art is non-formalizable =) In addition, it is impossible to understand some complex abstractions without knowing the subject area.
You won't understand code that has some data structure or algorithm that you don't know. You won't understand multithreading if you don't know how it works. You won't understand how cryptography works if you don't know the theory. Etc. etc.

V
Vladimir Korotenko, 2020-12-01
@firedragon

Someone smart joked that any C program is written to invert a value, everything else is just an obstacle to its goal.
Actually break into blocks. Simple programs are linear like any Unix utility.
A little later, they came up with object design, just for this.
Reduce the complexity of functions to a tolerable 7 parameters and group everything together.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question