每天一记录 —— 2022-09-13 星期二
请允许我先上一段代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void *abc()
{
printf("hallo chenjun ~_~ ! \n");
}
int add(int a, int b)
{
printf("enter add func !!!\n");
return (a+b);
}
int main(void)
{
void *pAbc = abc();
if (NULL == pAbc)
{
printf("pAbc start fail!\n");
return -1;
}
int c = add(1, 2);
printf("c = %d. \n", c);
printf("End main, exit !\n");
return 0;
}
疑惑:突然间脑子有点转不过来,为什么在main函数的第一行,只是给pAbc指针赋值它就已经是执行了一遍abc()函数了呢? 其实就行下面的 c 赋值了add(1, 2) 道理是一样的。不先执行add,如何能打印出 c 的值呢? --------- 每天记录一些,就会得到多一些 。