I want to memorize some hard codes in C

I want to memorize and learn C language syntax but this seems quite difficult for me even on the part of declaring the variables. For example, how could I memorize this variable declaration:

((type *)( (PCHAR)(address) - (ULONG_PTR)(&((type *)0->field)))

(Monstrous code of the seven seas)

I don’t really need to memorize exactly at this level but I come across several variable declarations, functions, code blocks where there are several challenges for me to memorize and even understand.

Can I memorize the syntax using Memory Palace or some other kind of method?

2 Likes

I think @Josh and @thinkaboutthebible can give u some advice as they are pro coders.

3 Likes

Random thought: I wonder if using reverse Polish notation might help with all those brackets.

Maybe you can think of what that code snippet does? Maybe you can visualise the process?

I’m very interested in what other people suggest: if you can remember code snippets like these the same techniques can be used for complex mathematical formulae.

4 Likes

Before you memorize something like that, how’s your knowledge of C syntax in general? If you know C syntax pretty well, then memorizing longer sets of code becomes easier.

Despite this, I find it best to only memorize certain code idioms and patterns unique to a programming language. Once you know these patterns, you can just combine them together to make more complicated programs. You also won’t be wedded to a specific coding implementation, as there’s often a million ways that you can program something.

4 Likes

Sounds like a good idea.

1 Like

I know the declaration of some types of variables and how to declare basic functions but not really the advanced part, reading a whole book of C might solve something.

2 Likes

@Manwithslowbrain first of all thank you for reminding me why I didn’t become a C programmer 25 years ago. And a tip of the hat to @Antelex for encouraging me to encourage a fellow programmer.

@Niten has a good thought to not remember the code but what the code does and sees the relationship to math. So what should you remember about these four values?
(1 + 2 * 3 + 4)
(1 + 2) * (3 + 4)
(1 + 2 * 3 ) + 4
1 + (2 * 3 + 4)
You don’t want to remember the patterns at all. You want to know the order of operations. So you remember PEMDAS. Then you know all sorts of patterns that are generated from that.

So follow @ehcolston’s recommendation to get to know your C syntax. Know all the possible ways you can declare variables. Know all the ways that pointer aritmetic is used and how and why you reference and dereference pointers. Sometimes you might create an acronym for the order of keywords and operators that form a useful pattern but like more complex patterns in coding, there’s always stackoverflow for that. I never felt a need to memorize anything after practicing the pattern until it was like knowing the alphabet.

One last “piece” of advice. You have to know the basics well to understand any variation. Take your avatar for example and his Diabelli Variations:
The theme:
image
has to be understood in key, rhythm, harmony, any other distinguishing feature. Then the variations aren’t as hard to remember:

image

Good luck. It takes about three to five years to be competent in all the forms of a language before you can read any of the combinations. My style of reading code or coding a difficult problem is to break down the parts until each part is easy. Then the whole thing is easy!

4 Likes

Thanks a lot for the help.

1 Like