摘要: 练习13-1 /* 打开与关闭文件 */ #include <stdio.h> int main(void) { char s[128]; FILE* fp; printf("请输入你要打开的文件"); scanf("%s", s); fp = fopen("*s", "r"); /* 打开文件 * 阅读全文
posted @ 2019-11-29 11:14 nightswatch-candle 阅读(999) 评论(0) 推荐(1)
摘要: 练习12-1 /* 用表示学生的结构体来显示高尾的信息 */ #include <stdio.h> #define NAME_LEN 64 /* 姓名的字符数 */ /* 表示学生的结构体 */ struct student { char name[NAME_LEN]; /* 姓名 */ int h 阅读全文
posted @ 2019-11-26 23:33 nightswatch-candle 阅读(1281) 评论(0) 推荐(1)
摘要: 练习11-1 /* 用指针实现的字符串的改写 */ #include <stdio.h> int main(void) { char* p = "123"; printf("p = \"%s\"\n", p); p = "456"+1; /* OK! */ printf("p = \"%s\"\n" 阅读全文
posted @ 2019-11-24 13:28 nightswatch-candle 阅读(1690) 评论(0) 推荐(0)
摘要: 练习10-1 #include <stdio.h> void adjust_point(int*n) { if (*n > 100) *n = 100; if (*n < 0) *n = 0; } int main() { int x; printf("请输入一个数:"); scanf("%d", 阅读全文
posted @ 2019-11-23 16:08 nightswatch-candle 阅读(1261) 评论(0) 推荐(0)
摘要: 练习9-1 /* 将字符串存储在数组中并显示(其2:初始化) */ #include <stdio.h> int main(void) { char str[] = "ABC\0DEF"; printf("字符串str为\"%s\"。\n", str); /* 显示 */ return 0; } 练 阅读全文
posted @ 2019-11-23 16:07 nightswatch-candle 阅读(2242) 评论(0) 推荐(1)
摘要: 练习8-1 #include<stdio.h> #define diff(x,y)(x-y) int main() { int x; int y; printf("x="); scanf("%d", &x); printf("y="); scanf("%d", &y); printf("%d", d 阅读全文
posted @ 2019-11-20 12:50 nightswatch-candle 阅读(2305) 评论(0) 推荐(0)
摘要: 练习7-1 #include <stdio.h> int main() { int n; printf("%d\t%d\t%d\n", sizeof 1,sizeof(unsigned)-1,sizeof n+2 ); //此行显示结果为 4 3 6 因为1的字节就是为4,而-1的字节也是4再减去- 阅读全文
posted @ 2019-11-19 13:11 nightswatch-candle 阅读(1979) 评论(1) 推荐(0)
摘要: 练习6-1 /* 求两个整数中的最小值 */ #include <stdio.h> /* 返回三个整数中的最小值 */ int min2(int a, int b) { int min = a; if (b < min) min = b; return min; } int main(void) { 阅读全文
posted @ 2019-11-14 18:08 nightswatch-candle 阅读(3456) 评论(1) 推荐(1)
摘要: 练习5-1 /* 依次把1、2、3、4、5 赋值给数组的每个元素并显示(使用for语句) */ #include <stdio.h> int main(void) { int i; int v[5]; /* int[5]数组 */ for (i = 0; i <5; i++) /* 为数组元素赋值 阅读全文
posted @ 2019-11-08 12:48 nightswatch-candle 阅读(4536) 评论(1) 推荐(3)
摘要: 练习4-1 练习4-2 练习4-3 练习4-4 练习4-5 练习4-6 练习4-7 练习4-8 练习4-9 练习4-10 练习4-11 练习4-12 练习4-13 练习4-14 练习4-15 练习4-16 练习4-17 练习4-18 练习4-19 练习4-20 练习4-21 练习4-22 练习4-2 阅读全文
posted @ 2019-11-06 23:51 nightswatch-candle 阅读(7514) 评论(0) 推荐(1)