kernighan-and-ritchie Questions
11
I'm a beginning programmer reading K&R, and I feel as if the book assumes a lot of previous knowledge. One aspect that confuses me is the actual representation, or should I say existence, of va...
Waltner asked 9/1, 2010 at 17:24
3
Solved
This question is about the 'function pointer' version of qsort from K&R (2e), section 5.11 (p118-121). There are a number of places where I don't understand why or how the casts work, and I sus...
Medalist asked 13/5, 2023 at 6:4
4
Solved
I am stumped by the 1.5.2 question in K&R. I googled for some time and found out that I have to supply the EOF input after entering the characters.
long nc = 0;
while (getchar() != EOF)
++nc;...
Caerphilly asked 26/1, 2014 at 14:2
6
Solved
What is useful about this C syntax — using 'K&R' style function declarations?
int func (p, p2)
void* p;
int p2;
{
return 0;
}
I was able to write this in Visual Studios 2010beta
// yes, ...
Noisy asked 27/10, 2009 at 12:59
9
Solved
I'm reading K&R's The C Programming Language and have become confused on putchar and getchar. I made a program where you enter 10 chars and the program prints them back out to the screen.
#inc...
Brookes asked 14/10, 2013 at 19:26
4
Solved
The C Programming Language by Brian Kernighan and Dennis Ritchie contains a lot of examples such as this famous one (K&R 2nd edition 1.1):
#include <stdio.h>
main()
{
printf("hello...
Moldboard asked 17/5, 2022 at 13:38
4
Solved
Well, reading "a bit old" book ("The C programming language", second edition, by Dennis Ritchie), I came a cross the following:
An external variable must be defined, exactly once, outside of any...
Khanate asked 30/8, 2012 at 14:51
6
I'm learning how to write programs in C using the k&r book (The C Programming Language) and I have a problem with one of the exercises. It's asking me to detect and remove a character in string...
Ley asked 7/1, 2009 at 1:44
13
Solved
I've been working through some books on C trying to get my C legs (sea-legs! Get it?!). I've just finished exercise 1-9 from the K&R book, which for reference is to "write a program to copy its...
Careworn asked 23/7, 2015 at 21:0
6
Solved
I'm learning C from K&R's "The C Programming Language" book. I'm doing the exercises specified in the book. I'm on exercise number 1.16, but I don't understand it.
Exercise 1.16:
Revise th...
Consciencestricken asked 27/2, 2013 at 18:41
4
In the K&R ANSI C book I have stumbled upon a piece of code where a pointer to a function is used. I think I understand the idea behind pointers to functions, but the example presented in the b...
Emery asked 23/12, 2020 at 13:49
5
Solved
I am currently reading K&R's book and typing in the examples from the first section, and there are a couple of examples such as this:
while((c = getchar()) != EOF) {
//do something
}
I am t...
Pericline asked 13/7, 2009 at 11:32
5
Solved
On pg. 109 of K&R, we see:
void writelines(char *lineptr[], int nlines)
{
while (nlines -- > 0) printf("%s\n", *lineptr++);
}
I'm confused about what *lineptr++ does exactly. From my und...
Clamant asked 8/5, 2009 at 2:52
1
Solved
In this golfing answer I saw a trick where the return value is the second parameter which is not passed in.
int f(i, j)
{
j = i;
}
int main()
{
return f(3);
}
From gcc's assembly output it...
Edee asked 9/8, 2019 at 22:35
5
Solved
This code comes from K&R. I have read it several times, but it still seems to escape my grasp.
#define BUFSIZE 100
char buf[BUFSIZE];
int bufp = 0;
int getch(void)
{
return(bufp>0)?buf[-...
Picrite asked 14/12, 2011 at 14:0
3
Solved
The book The C Programming Language by Kernighan and Ritchie, second edition states on page 43 in the chapter about Type Conversions:
Another example of char to int conversion is the function lowe...
Pterous asked 25/12, 2018 at 23:28
3
Solved
#include <stdio.h>
struct Header
{
unsigned long long int alignment;
};
int main(void)
{
struct Header header; // note: we can loose the 'struct' in C++
struct Header* pheader = &hea...
Bod asked 25/10, 2018 at 2:17
5
Solved
I'm writing a program to count blanks, tabs, and newlines. I remember what the escape sequence for tabs and newlines are, but what about blanks? \b? Or is that backspace?
Hetti asked 21/7, 2010 at 23:36
4
Solved
I'm studying K&R book. Currently i'm reading function getop() at p.78.
I do understand the code but i need clarifications about 2 things.
The code of getop() is as follows:
int getch(void);
...
Seaquake asked 23/10, 2015 at 9:45
2
Solved
I've been reading through K&R and encountered a point of confusion in the implementation of malloc() included.
typedef long Align; /* for alignment to long boundary */
union header { /*...
Betteann asked 12/3, 2018 at 0:35
4
Solved
This is an excerpt from the book on C by Kernighan and Ritchie. It shows how to implement a version of malloc. Although well commented, I am having great difficulty in understanding it. Can somebod...
Liquescent asked 31/10, 2012 at 8:45
2
Solved
I am trying to understand some basics of C. KRC's The C Programming Language says
A function call is a postfix expression, called the function designator, followed by parentheses containing a po...
Consider asked 10/8, 2017 at 13:56
4
Solved
I am reading "The C programming Language" by Brian W. Kernighan and Dennis M. Ritchie. In chapter 1.2 "Variables and Arithmetic Expressions" they demonstrate a simple Fahrenheit to Celsius converte...
Antispasmodic asked 6/5, 2017 at 10:0
2
Is the Most Vexing Parse rooted in the ambiguity about whether or not to use void as the parameter of a function declaration that takes no arguments?
As an example, the following code compiles wit...
Hartwell asked 17/1, 2017 at 18:37
2
Solved
Can somebody please take a look at this and tell me what is wrong. I have 3 errors:
error: Conflicting types for getline
error: too few arguments to function call, expected 3 have 2
error: conflic...
Hi asked 9/5, 2016 at 16:49
1 Next >
© 2022 - 2025 — McMap. All rights reserved.