
《C程序设计语言》
文章平均质量分 79
mykelia
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
《C程序设计语言》练习1-9
问题:编写一个将输出复制到输入的程序,并将其中的连续的多个空格用一个空格代替。 本例关键是要认识如何更新前一个字符及if-else语句,逻辑或的运用! if语句实现: #include #define NOBLANK 'a' /* replace string of blanks with a single blank */ int main() { int c, las原创 2013-01-30 11:30:51 · 538 阅读 · 0 评论 -
练习1-12
编写一个程序,以每行一个单词的形式打印其输入。 #include #define IN 1 #define OUT 0 int main() { int c, state; state = OUT; while ((c = getchar()) != EOF) { if (c == ' ' || c == '\t' || c == '\n')原创 2014-01-13 16:42:46 · 600 阅读 · 0 评论 -
第五章 二
练习5-7 重写readlines,将输入的文本行存储到由main函数提供的一个数组中,而不是alloc分配的存储空间中。 int readlines(char *lineptr[], int maxline, char *linetostore) { int len, nlines; char *p = linetostore; char *linetop = p +原创 2014-01-21 22:26:12 · 873 阅读 · 0 评论 -
第四章(二)
----2013-01-19---- 习题4-7 编写一个函数ungets(s),将整个字符串s压回到输入中。ungets函数需要使用buf和bufp吗?它能否仅使用ungetch函数? 代码如下: void ungets(char s[]) { int i; void ungetch(int); for (i = 0; i < strlen(s) && s[原创 2014-01-19 20:12:37 · 862 阅读 · 0 评论 -
第四章代码
练习4-1 (60页) int strrindex(char s[], char t[]) { int i, j, k; for (i = strlen(s) - strlen(t); i >= 0; i--) { for (j = i, k = 0; t[k] = s[j] && t[k] != '\0'; j++, k++) ;原创 2014-01-16 15:36:00 · 475 阅读 · 0 评论 -
第五章
练习5-1 如果符号-或+后面跟的不是数字,getint函数将把符号视为0的有效表达方式。修改该函数,将这个形式的+或者-符号重新写回到输入流。 说明:题目理解起来不是特别清晰,不知道是翻译过来的问题还是我理解的问题,参考了一下答案。 #include #include int getch(void); void ungetch(int); int getint(int); int原创 2014-01-20 15:41:13 · 693 阅读 · 1 评论 -
第六章-结构
问题:E:\code\test_c\main.c|20|error: conflicting types for 'strdup'| E:\code\test_c\main.c|69|error: conflicting types for 'strdup'| 不知道为什么会这样? #include #include #include #include #d原创 2014-02-18 18:18:37 · 728 阅读 · 0 评论