r/learnprogramming • • 3d ago

C programming language learning guide

Where can i learn C from basic ?

10 Upvotes

31 comments sorted by

View all comments

Show parent comment

2

u/Ratfus 2d 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 2d 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 2d ago

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