kernighan-and-ritchie

    2热度

    1回答

    引用从Kernighan和Ritchie代码(第2版第188页), static Header* morecore(unsigned nu) { char *cp, *sbrk(int); Header* up; if (nu < NALLOC) nu = NALLOC; cp = sbrk(nu * sizeof(Header));

    0热度

    1回答

    我看到这里的答案:http://clc-wiki.net/wiki/K%26R2_solutions:Chapter_2:Exercise_6 和我测试过第一,但在这个部分: x = 29638; y = 999; p = 10; n = 8; return (x & ((~0 << (p + 1)) | (~(~0 << (p + 1 - n))))) 在一份文件给它我6,但在程序

    2热度

    2回答

    再次返回C newb。我正在努力参加K和R C的练习,并尝试练习1-14,我非常难过。 我的解决方案可行,但并不总是正确的,我正在寻求帮助来完善我写的内容,或者如果有更好的(更容易理解!)的方式! 我的脚本: #include <stdio.h> /* How many times a character appears in an array */ main() { int c

    2热度

    2回答

    虽然通过练习3-5中的在C编程语言,我遇到了以下意外行为。 #include <stdio.h> #include <string.h> // inspired by: http://www.eng.uerj.br/~fariasol/disciplinas/LABPROG/C_language/Kernighan_and_Ritchie/solved-exercises/solved-ex

    -1热度

    2回答

    我用K & R. 现在的功能代码“getint()”到“C程序设计书”走出如下: - > #include<stdio.h> #define BUFSIZE 100 char buf[BUFSIZE]; int bufp = 0; int getch(void) { return (bufp > 0)?buf[--bufp]:getchar(); } void ung

    1热度

    1回答

    按照我的方式工作K & R我偶然发现了这种意外的行为。考虑以下代码: #include <stdio.h> #define MAXWLEN 10 /* maximum word length */ #define MAXHISTWIDTH 10 /* maximum histogram width */ #define IN 1 /* inside a word */ #

    0热度

    3回答

    我是编程新手,我决定从c开始。我正在使用K & R的书,并且有这个练习,它要求编写一个程序,将输入复制到输出,用一个空白替换一个或多个空白。然而,当我编写我的程序(我确信它不正确,但没关系,因为我在这里学习),我想知道我做错了什么。还有一点需要注意的是:当我用3个空格键入我的名字时,它减少到2个,但是当使用两个或一个空格时,没有任何反应。代码下面贴 #include <stdio.h> #inc

    14热度

    2回答

    我想了解下KRC的一些基本的C程序设计语言说 函数调用是一个后缀表达式,称为功能标志,然后是包含括号可能是空的,用逗号分隔赋值表达式列表(Par.A7.17), 构成函数的参数。 在一个函数调用,什么是运营商,什么是操作数? 是()运营商? 函数名是操作数吗? 是否在()操作数内的参数? 函数指示符是函数调用的同义词吗? 谢谢。

    -1热度

    3回答

    分配: 写一个函数反方向(S)这尊字符串s.Use它写在某时刻尊其输入线 这里是一个程序我试图在解决它: #include <stdio.h> #define MAXLINE 1000 int getlinex(char line[], int maxline); int main(){ int len, j; char line[MAXLINE]; cha

    3热度

    2回答

    为什么这个Code在整个声明的中间无处(中间函数定义),不抛出错误? 1)为什么它在语法上是正确的。 2)这样做有什么用处? #include <stdio.h> void func(int, int); int main() { int a, b; a = 10; b = 20; func(a, b); return 0; } voi