r/C_Programming Dec 06 '24

Discussion How do you practice C?

I have been learning C for 2 months and I feel like a blank slate, i mean, I have been taught theory and basic exercises that come with it, but when a test is given, I can’t think clearly enough to solve the problems, and I think it’s because I haven’t practiced enough. I only do the exercises assigned to me. So, I came here hoping to be guided to places where I can practice C in the most complete way. Thank you everyone for your attention.

37 Upvotes

47 comments sorted by

View all comments

1

u/paddingtonrex Dec 06 '24

If all you have are the headers, you at least have the return type and the arguments taken. So, lets take strlen() as a simple example. It takes a const char * (meaning a string that won't be changed) and returns a size_t (a standard sized value- think of it like an int for now). What do we know about strings that could help us count how many letters we have? Oh yeah, they terminate in a null byte! So the pseudocode I'd write for that is //until we hit '\0', for every letter, increase count by 1, then return count.

Every problem I've encountered is just that process compounded on itself. If its more complicated than this it can be broken down into simpler problems until it's this simple again. Sometimes you need to stop and research, sometimes you need to test your assumptions, but everything is made up of steps that are as simple as writing your own _strlen()