分析程序结果,分析过程我们就写在程序注释里面。
写出下列代码的输出内容
#include <stdio.h>
int inc(int a)
{
return (++a);
}
int multi(int *a, int *b, int *c)
{
return (*c = *a * *b);
}
typedef int (FUNC1)(int in);
typedef int (FUNC2)(int *, int *, int *);
void show(FUNC2 fun, int arg1, int *arg2)
{
FUNC1 *p = &inc;//p指针指向inc函数
int temp = p(arg1);//调用p后,参数arg1增1返回,下面传进来的参数是10,增1后返回temp=11
fun(&temp, &arg1, arg2);//调用fun位传进来multi,调用multi后,前两个参数指向的整数相乘,结构返回到第三个参数
printf("%d\n", *arg2);//即得到结果为*arg2 = 11*10 =110,所以结果是110
}
int main()
{
int a;
show(multi, 10, &a);
return 0;
}
给出下面程序的答案:
#include <iostream>
#include <string.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
typedef struct