r/learnprogramming • • 1d ago

C programming language learning guide

Where can i learn C from basic ?

8 Upvotes

31 comments sorted by

5

u/MrShaunce 1d ago

Buy a book. Read it. Type in and run the examples. Do the exercises. 

1

u/DolCE_121 1d ago

Okay I will buy one

1

u/Lopsided_Cap_6606 1d ago

What are good books?

1

u/MrShaunce 1d ago

I can't recommend any unfortunately, haven't used an intro C book in decades.

1

u/Erica_Vaughan_0_4148 1d ago

Tried it, works

2

u/Aggravating_Chef_656 1d ago

https://github.com/MarkusMachel/C-Project-Based-Tutorials

take a look on this. But go on the original, my fork is out of date

1

u/DolCE_121 1d ago

GITHUB 💀

1

u/SprinklesFresh5693 1d ago

You will have to learn git ans how github works sooner or later if you want to be a programmer though.

1

u/DolCE_121 1d ago

Yeah to learn that as well 😔

1

u/SprinklesFresh5693 1d ago

Git is suepr easy, you can learn it in a day after you get some experience using a prigramming language.

It might be intimidating at first, but theres plenty of tutorials and short books on how to use it

1

u/DolCE_121 1d ago

Yeah I am watching a video on it

6

u/ImpluseThrowAway 1d ago

Kernighan and Ritchie

2

u/Ratfus 1d ago

Apparently, Ritchie would respond to stranger's emails, despite his niche fame.

Kernighan also seems like the type to reply to stranger's emails. Both of them are very modest, despite their fame.

2

u/lisnter 1d ago

K&R is a good way to go. I read it 40 years ago and learned enough to start my summer job. The book isn't very long so you can read it in a few days. It's best if you have a simple project in mind so you have something to apply the concepts to; but keep it simple to avoid overwhelming yourself with every detail.

These days a lot of the complexity is just setting up the environment properly though for vanilla C, Visual Studio Code gets it done painlessly (or good-old gcc).

2

u/twr14152 1d ago edited 1d ago

You really read that in a couple of days? That was a month of agony for me. Had to dedicated one hour every morning for it. Couldn't take any more of it than one hour. And i had to restart at least once. It was hard as hell to stay focused on it. There was good material in there for sure but the logic in the example were so recursive i had to bend myself into a pretzel to eek out understanding. The partial code snippets and referencing of earlier functions in the examples were exhausting. Other than that i did get through it, and have the scars to show for it. When i hear people breezing through it, it really makes me question my intellectual choices in life.

2

u/Ratfus 1d ago

Could someone read that in a few days? Sure. Read and understand it, absolutely not; unless, you were already extremely knowledgeable about programming and C.

2

u/lisnter 21h ago

I had taught myself BASIC and Pascal in High School and understood the concepts of control flow, variables, arrays, etc. so I just needed C syntax to get started. Keep in mind, this was ~1985 so pretty much all one had to work with was libc, a text editor (epsilon/emacs clone) and make; I didn't need to know much to get started. Also, the programming team was very small (3) and very inexperienced so my lack of extensive C experience was not really out of place.

I read half/third of the book over a weekend before I started the job, learned while doing and read the rest of K&R over about a week. We were also not building an Amazon pre-cursor - it was a relatively simple Gantt chart project management tool for a compay that wanted to branch out into commercial software. Again, in 1985 it didn't take much.

This was my summer job so I left in September but the CFO was a neighbor and friend of my parents who got me the job - he said, "Hey lisnter, you know C right?" - and the project was cancelled soon after I left. This company didn't have any business trying to branch out - they did a post-production for Hollywood movies - but the experience was way more than other college students my age which was critical to get additional real programming jobs the rest of my undergrad career.

The coolest contribution I made to that project was a nearly instantaneous screen-update function. Back then, there were two main ways to write to the screen (80x25 text only): printf() and an interrupt. Both of which were horribly slow. Fortunately, I was an avid reader of Byte magazine and had just learned about the memory map of the IBM PC. In these early days, everything was far simpler - some would say dangerously so - and you could write anywhere in memory you wanted if you had a pointer to it. All I had to do was define a pointer and initialize if with the right value; something like:

int *videoMem = 0xa0000 ; // start of IBMPC video memory

and I would de-reference videoMem to write the value:

*videoMem = ( int )'A' ;

++videoMem ;

This ran extremely fast and could update the screen practically instantaneously. The business logic would hand me an 80x25 array (only 2000 elements) with the right values already loaded and I'd just pump it out to the screen. Since this was text-only it could use the special IBM PC line-art codes (above 0x7f) to make some convincing boxes and charts.

Fun days.

3

u/twr14152 21h ago

Cool man. Thanks for sharing that. That was a unique time.

1

u/Ratfus 1d ago

Setting up the environment is a perfect task for chat gpt. A lot of home brewing commands that I'm not too fond of memorizing, and will only ever use for setting up applications.

Things that took me a few hours, could have easily taken 20+ without it. Had a brutal time trying to set up vs code, to program an atiny in assembly.

1

u/UpbeatYear3926 1d ago

40 years ago wow

1

u/Flimsy-Importance313 1d ago

CS50 has great lectures and exercises. It is almost as good as professional C lectures for the base at least.

1

u/DolCE_121 1d ago

Okay got it

1

u/ExtraTNT 1d ago

read the book, then fuck around and find out… build games, build utils, fuck things up, but never give up

1

u/DolCE_121 1d ago

💪🫡

2

u/vikicrays 1d ago

here are some free educational resources just in case anything in here can help with tuition or take the place of classes you need to pay for to get a degree or increase your skills:

the university of the people https://www.uopeople.edu), or WorldQuant University https://www.wqu.edu where tuition is free (i believe there is a nominal fee to sign up and premium services are also offered for a fee).

stanford online https://online.stanford.edu/free-courses and saylor academy https://www.saylor.org/Home both offer a range of free classes, certifications, and paths to degrees.

if you’re looking to learn to code, check out the odin project https://www.theodinproject.com/ or w3schools https://www.w3schools.com/ which are also free.

carnegie mellon is offering their entire line of coding classes on youtube for free includes 15-110 Principles of Computing and 11-768 Al Agents. https://www.cs.cmu.edu/learn/index

if you’re looking into community colleges or a 2 or 4 year degree, check out sallie https://www.sallie.com/scholarships/scholly which has a searchable database of available college scholarships.

2

u/Yarrowleaf 1d ago

Learn C the hard way is a good book, my friend learned from it and gave it to me and I used it.

1

u/Humble_Anxiety_9534 1d ago

get linux it's bult in? or anything that runs gcc or clang? they are reliable c compilers. but the true magic of C is in embedded code. make something it's easier in embedded and linux.

1

u/mscott-61 3h ago

If you're starting from zero, look for K. N. King's C Programming: A Modern Approach; work through the exercises and compile each example as you go.

0

u/Electronic-Yam-69 1d ago

Can't be done today.  People have forgotten how.