10.31新生培训

10.31新生培训

代码的调试之旅 —— Debug

  1. VS2015
    • F10 step out
    • F11 step into
  2. codeblocks
    • shitf F7 step into
    • F7 step
  3. gdb
    • next 执行下一行语句
    • step 同上,有函数则会进入函数
    • run 运行到断点处
    • breakpoint 下断点
    • start 停在main的第一行语句前
    • print 打印变量
    • display 跟踪一个变量
    • undisplay 取消跟踪
    • info locals 查看局部变量
    • list 列出最近十行代码

BUG

1
2
3
4
5
6
7
8
9
10
// error1.c
#include<stdio.h>

int index(void)
{
for (i = 0; i < 2; i++) {
printf("Hello World!");
}

return 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//error2.c
#include<stdio.h>

int main(void)
{
char a;
char b[2] = 'ab';

a = "c";

printf("b = %s and a = %c\n", b, a);

return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//error_last.c
#include <stdio.h>
#include <stdlib.h>

typedef struct yue
{
int num;
struct yue *next;
}node;

struct yue *creat(int a)
{
struct yue *head, *pold, *p;

int i;

p = head = pold;

for (i = 1; i<a; i++)
{
p = (struct yue *)malloc(sizeof(struct yue));
p->num = i;
pold->next = p;
pold = p;
}

p->num = a;
p->next = head;

return head;
};

void print(struct yue *p1, int b)
{
node *p;

int n;

p = p1;

for (n = 1; n< b - 1; n++)
{
printf("%5d", p->num);
p = p->next;
}

}

int main(void)
{
node *p2;

int x;

printf("input x:\n");
scanf("%d", &x);

p2 = creat(x);
print(p2, x);

return 0;
}

知识积淀 —— 博客 OR 笔记

For yourself

- 作为知识的积淀,记录了你的成长
- 你确定你真的掌握了吗?如果你能把该知识点用文字描述出来,那么你就算是真的掌握了
- 备忘

For others

- 知识分享
- 交友
- 面试时加分

How can I write?

就想写日记一样, 多写,多看就知道怎么写了

第三方博客

- http://www.diandian.com/
- http://blog.csdn.net/
- 百度、新浪 等等

PS: 可以从我博客的友情链接中发现协会其他人的博客

推荐文章

  1. 前言: http://zhuanlan.zhihu.com/Evi1m0/19695848
  2. 因为所以 http://zhuanlan.zhihu.com/Evi1m0/19700177
  3. 黑客眼中的黑客 http://zhuanlan.zhihu.com/Evi1m0/19702939
  4. 学会使用搜索引擎 http://zhuanlan.zhihu.com/Evi1m0/19714051
  5. 首先,你需要先学会编程 http://zhuanlan.zhihu.com/Evi1m0/19733294
  6. 你们眼中的黑客 —— 脚本小子 http://zhuanlan.zhihu.com/Evi1m0/19773598
Author

Hcamael

Posted on

2015-10-31

Updated on

2017-07-26

Licensed under