The C Programming Language

Author: Brian W. Kernighan, Dennis M. Ritchie
4.6
All Stack Overflow 79
This Year Reddit 70
This Month Reddit 7

The C Programming Language

4.6

Review Date:

Comments

by anonymous   2018-06-05
IMHO, the count for C is misleading - `NULL`, `size_t` though not listed as keywords are widely used [macros]( http://tigcc.ticalc.org/doc/stddef.html), including K&R's [second}(https://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628) edition. On a related note, Python 3's count of 33 includes `None`, `True` and `False` as keywords.
by HueronEnter   2018-03-19

I'm seeing a very common pattern in the thread here. Any software engineer/programmer that's worth its... awkward complexity is measured in their skill.

That said skill isn't the in-depth knowledge of a language, where you can codegolf the mona lisa in various opengl implementations in cutting edge obfuscated machine opcode and mnemonics, but rather:

  • Algorithmisation: Knowing how to write and optimize algorithms.

  • Comprehensive understanding of the fundamentals

  • Abstracts, and its related concepts

  • Knowing, recognizing patterns

  • Applying Design Patterns that work

  • Knowing Data structures, and what works where

A good programmer might be able to code a small software or a small webpage in a constricted time period for a small vendor.

A great programmer only has to look at a language for a day to start programming.

A week is enough to be fluent. Two weeks are sufficient to write vendor code.

CompSci is not some magic bullshit, but some cannot stomach it. You should absolutely look into the "academics":

  • SOLID for programming

  • ACID for databases

  • the timings, O(n), O(1), O(n^2), such.

  • Math abstracts

  • Optimization

  • Invariants

  • Automata theory

  • Software development methodologies

Then also look into:

  • AGILE. - http://agilemanifesto.org/

  • Test-Driven development (Test-First)

  • Behavior-Driven development

  • Unit testing

  • Integration testing

  • Testing in general

Mind you, not as hard as a college or university might teach it - that's their business. You should do the reading, understand, and apply it in practice.

Code in :

  • C to see how far we've gone.

  • C++ to learn a language that's future-proof and won't go anywhere.

  • Python to see a fruity and tasty environment that does a lot of things.

  • Bash/shell/variants to know more concepts

  • Lisp : Actually don't bother with LISP, it's pure cancer with the functional lists it does. But do take a look, maybe write a few lines of code.

I would be a bad programmer if I didn't recommend:

One very interesting and important point: To get good jobs, you have to know some technologies. Don't just brush languages. Stack overflow is your friend.

And for the wisest words that many seem to forget: Keep it simple, do more with less. Avoid all and any side-effects.

Edit: Damn reddit and its formatting...

Edit 2: End-goal of it all: Swimming in all the cash, baby!

by reddilada   2018-03-19

You'll do fine. You're a physicist, second smartest people in the universe behind the mathematicians :)

Pick up a copy of 2nd edition K&R C and go through it. It's a short book and has everything you need to know about C.

I doubt they are going to throw you in too deep and it's likely they will have some experience with the environment since they seem to be specifying it. That is, you should have a number of tools at your disposal. If you get stuck, just ask someone.

by Bizkitgto   2018-03-19

I'd start with Harvard's CS50 on edx, it's the best course you'll find anywhere bar none. The instructor, Dave Malan is world class. The first half of the CS50 lectures are on C and on youtube. There's also r/cs50.

Also, the Richard Buckland lectures are all up in youtube as well, really good intro to C programming. People love this guy!

Here is the Aalto C Programming MOOC based on K&R.

You can learn C, all you need is a text editor (like notepad or sublime), and the terminal/command line. You don't need any internet connection whatsoever.

I recommend getting this book C Programming: A Modern Approach , it's great for beginner's, and you can try going though the examples. You can also try going through all the problem's in K&R 's C Programming (what many refer to as 'The C Bible') book if you want to be a C Ninja.

Here is a guide on how to compile C programs on a Linux system.

You can find used copies or PDF's of these books online if you don't want to pay full price. I like having a hard copy in front of me when learning as I can flip back and fourth quickly. Since you want to learn C - you should read K&R 's The C Programming Language (the bible for C) at some point.

by anonymous   2018-03-19

If your libc contains an itoa() function, you can use it to convert an integer to a string.
Otherwise you'll have to write the code to convert a number to a string yourself.

itoa() implementation from C Programming Language, 2nd Edition - Kernighan and Ritchie page 64:

/* itoa: convert n to characters in s */
void itoa(int n, char s[])
{
   int i, sign;

   if ((sign = n) < 0)  /* record sign */
      n = -n;           /* make n positive */
   i = 0;
   do {  /* generate digits in reverse order */
      s[i++] = n % 10 + '0';  /* get next digit */
   } while ((n /= 10) > 0);   /* delete it */
   if (sign < 0)
      s[i++] = '-';
   s[i] = '\0';
   reverse(s);
}
by Bizkitgto   2017-12-06

I'd start with Harvard's CS50 on edx, it's the best course you'll find anywhere bar none. The instructor, Dave Malan is world class. The first half of the CS50 lectures are on C and on youtube. There's also r/cs50.

Also, the Richard Buckland lectures are all up in youtube as well, really good intro to C programming. People love this guy!

Here is the Aalto C Programming MOOC based on K&R.

If you want to learn C - you should read K&R 's The C Programming Language (the bible for C) at some point.


Stackoverflow is your friend where you can ask any question you have or bounce ideas off of others.

Learn Java OOP (here is an excellent course): MOOC

Free Code Camp for web design

Build your own operating system: NAND2TETRIS

Cave of Programming : All kinds of programming

Open Source Society University: This is a solid path for those of you who want to complete a Computer Science course on your own time, for free, with courses from the best universities in the World.

r/arduino for some embedded programming fun!

.....and of course for anything under the sun: https://www.edx.org/ & https://www.coursera.org/


For BSD: https://www.freebsd.org/

For Linux: https://www.archlinux.org/


For x86 assembly language: http://opensecuritytraining.info/IntroX86.html [How far down the rabbit hole do you want to go?]

Edit: I thought Scott Young's MIT Challenge. He completed the MIT Computer Science program in under 12 months using nothing but online resources.

by csp256   2017-12-06

Good news is you have previous experience and C is a very simple language.

Learn C The Hard Way has some weird shit in it (wtf does "make is your Python now" even supposed to mean?) but it is largely good and do tend to recommend it despite the warts.

Really though, why not go straight to the source?

Just make sure you master pointers. It is really useful to understand what memory is on a physical or near physical level to understand pointers. It is one of those concepts that makes instant sense if you come from a hardware point of view, but can trip up newbies with a software point of view.

by F14D   2017-12-06

K&R's C Book is also very good.

by anonymous   2017-11-13
@97amarnathk It was in pre-standard and in first standard of C language - C89 (adopted in 1989 as you could surmise). It was removed in all consecutive C standards. I read it in the famous C book from K&R: https://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628
by jasonlhy   2017-10-23
C is a very "strict" language. It do the right thing only if you write the right code. It has many undefined behaviors. One of the undefined behaviors I found when I studied the compiler course. The purposed grammar from https://www.amazon.com/Programming-Language-Brian-W-Kernigha... allows this kind of structure, there can be statements after the switch but before the case labels. gcc also accepts this, but those statements will not be executed. Note: code modified from https://www.tutorialspoint.com/cprogramming/switch_statement...

#include "stdio.h"

int main () {

   /* local variable definition */
   char grade = 'B';
   int a = 1;

   switch(grade) {
      printf("great!\n" );
      a = a + 1;
      
      case 'A' :
         printf("Excellent!\n" );
         break;
      case 'B' :
      case 'C' :
         printf("Well done\n" );
         printf("a: %d\n", a);
         break;
      case 'D' :
         printf("You passed\n" );
         break;
      case 'F' :
         printf("Better try again\n" );
         break;
      default :
         printf("Invalid grade\n" );
   }
   
   printf("Your grade is  %c\n", grade );
 
   return 0;
}