Questions tagged [kernighan-and-ritchie]

Questions about or related to the book "The C Programming Language" (which is also known as K&R) by Brian Kernighan and Dennis Ritchie.

Questions about or related to the book "The C Programming Language" (which is also known as K&R) by Brian Kernighan and Dennis Ritchie.

The authors came together to write the book in conjunction with the language's early development at AT&T Bell Labs.

There have been two editions of the book. The first edition, commonly called "K&R1", was published in 1978 and describes a pre-standard version of the language. This edition is now mostly of historical interest.

The second edition, "K&R2", was first published in 1988 with some updates of the book to meet the version of the language standardized by ANSI in 1989.

(The 1989 ANSI C standard was republished by ISO in 1990 and a normative amendment was released in 1995. New versions of the standard were published in 1999 and 2011. There have been no new editions of K&R covering any of the changes to the language since 1990.)

335 questions
-2
votes
3 answers

Can't print element of char array

I am a little confused. I write in pure C. The following code doesn't work: char arr[] = "0x123"; printf(arr[0]); It is just an example. IDE(Code::Blocks) generates this: Program recieved signal SIGSEGV, Sigmentation fault. Why does this code not…
Denis
  • 719
  • 2
  • 8
  • 23
-2
votes
3 answers

Missing main() prevents executable creation while linking

I am using Microsoft Visual C++ on Windows. I compiled it fine without any errors. However, when I tried to execute it, I got two errors. I read the debugging errors, and I could not understand them. I am somewhat a newbie in C programming. This…
Joseph Lee
  • 529
  • 1
  • 5
  • 10
-3
votes
4 answers

Infinite loop when getting a line with getchar()

I was trying an exercise from K&R (ex 1-17), and I came up with my own solution. The problem is that my program appears to hang, perhaps in an infinite loop. I omitted the NUL ('\0') character insertion as I find C generally automatically attaches…
Somu
  • 83
  • 10
-4
votes
2 answers

K&R exercise 1-23

I have two questions related to the titular exercise, from The C Programming Language. I'm sure that they've both been answered before, so either a direct answer or a link to a previous post (I couldn't find any) would be appreciated. The exercise…
-5
votes
1 answer

K&R, find longest line, same code but not working?

I've just started to read K&R and on pages 32-33, there is a code that finds the longest line among the inputs. I nearly completely copy-pasted the code given in the book, just added some comment lines to make the code more understandable for me.…
Said
  • 187
  • 1
  • 2
  • 11
1 2 3
22
23