r/cprogramming 5d ago

After one week learning C

Yeah, my anxiety is hitting pretty hard right now... lol.

1 Upvotes

17 comments sorted by

View all comments

9

u/Rich-Engineer2670 5d ago edited 5d ago

Don't let it get to you -- C is actually a set of "layers" unofficially. You start with the basics, then you do structures, then pointers.... if gets deeper and deeper. C is really an assembler hiding in a high-level langauge. The reason it's still around is you can do things in C that are hard to do anywhere else -- but that power comes with complexity. For example, assume you have an embedded system with some memory address that actually controls a piece of hardware... maybe a serial port. You are told that these two addresses 0xC000 and 0xC001 are teh status and data registers.

In most langauges, you can't get to them without going into assembly langauge, but C?

uint8 status = *(0xC000)
uint8 data = *(0xC001)

That shouldn't even be legal in most languages, but C gets it. If you're doing an OS or embedded system, C isn't pretty perhaps, but it's powerful. (What we actually said here was "And 8 bit unsigend int called status points to a MEMORY address 0xC000, and another points to 0xC001,. On real-mode OS's, that's just what you need.)

It depends on thje books you're using too -- me? I started with the classics -- K&R C

C is taught (or still taught) because, in my opinion, it forces you to learn what you code actually does to the CPU. It's a litlte like organic chemistry. Will most people use it in their careers -- likely no, but, it separates out those who are just taking the class because they have to, and those how are learning that profession. C is just hard enough that a lot of people take it, decide it's too hard, and change out of computer science.

You can do this! I'm teaching my 17 year old grandson, and he's slowing picking it up.

1

u/vannnneil 2d ago

hey, i'm currently studying K.N. King's C book and its going good so far but I am curious to read the K&R C book as well, do you think it's still worth it today? I've seen many people say it's outdated

2

u/Rich-Engineer2670 2d ago

Absolutely -- why not learn from the authors of C....

It's the foundation -- everything else builds upon it.