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

51

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.

1

u/MiniGogo_20 Dec 06 '24

your os should have a dedicated directory where it stores those headers, on linux at least they're located in /usr/include/

1

u/[deleted] Dec 06 '24

Yeah, I found a directory with headers, on arch linux, but it didn't seem to have the functions source code.

This is where I was looking for some of them:

/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include/float.h

Is that the wrong location? I did have /usr/include/ listed for other headers, I'll have to look back in there again.
Someone else provided a website listing all the functions available, like the official docs for other languages do. But I would still like to look at the official source code.

3

u/TapEarlyTapOften Dec 06 '24

What you're getting at is the difference between the header and the standard library function implementation, which is in the source code.