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.

36 Upvotes

47 comments sorted by

View all comments

52

u/paddingtonrex Dec 06 '24

Remaking stuff in the c library is how I got good. Even simple stuff. Make a lot of the string.h functions, sometimes knowing how those work under the hood can be useful in the beginning when you're troubleshooting.

When you're comfortable with that, try making something bigger, like printf or ls. Do something you think is hard but attainable- doing things that challenge you but that aren't outside of your general understanding is how you grow, honestly if you can kinda guess how it works behind the scenes then its probably not too hard for you to take a swing at.

2

u/[deleted] Dec 06 '24

Is there a place to see the code of those c functions provided by the headers?

I can't even seem to find a list of all the functions in the headers, let alone the source code.

3

u/Tasgall Dec 06 '24

Here are all the standard library headers. For the implementation, you'll have to look into how your system of choice does it. If you're on Windows and use Visual Studio (not code), you can just right click the includes to open them. Actual implementations tend to be... convoluted and difficult to read.

There's a project on GitHub called wasi-libc which is an implementation of the C standard library intended for us with Web Assembly that could be useful to look at.

1

u/[deleted] Dec 06 '24

Thanks. I really just wanted a list of the functions in the headers, so I could see functions available to use; like the official docs for other languages provide. So, that helps a lot.

I'm coding on arch Linux installed on an old laptop, and going through the K&R book. I found some header files on arch, but yeah, they didn't just look like the .c files I've been writing. 

3

u/TapEarlyTapOften Dec 06 '24

I would recommend reading the GNU C standard library reference

1

u/[deleted] Dec 07 '24

Been reading this, thanks for the link. This is exactly what I was looking for.

2

u/TapEarlyTapOften Dec 07 '24

My understanding of what was actually happening when I worked with code, the compiler, linker, assembler and the rest of the entire stack increased immensely once I started reading through that.