谁能解释一下这个程序 C
解决时间 2021-01-23 13:51
- 提问者网友:書生途
- 2021-01-22 14:33
#include
#include
fut(int * * s, int p[2][3]) {**s=p[1][1];}
main()
{ int a[2][3]={1,3,5,7,9,11},*p;
p=(int *) malloc(sizeof(int));fut(&p,a);printf("%d\n",*p);
}
p=(int *) malloc(sizeof(int))什么意思???
fut(int * * s, int p[2][3]) {**s=p[1][1];} s前面为什么两个星号????
最佳答案
- 五星知识达人网友:北方的南先生
- 2021-01-22 16:05
p=(int *) malloc(sizeof(int))
申请一段大小为sizeof(int)的空间 并把该段空间的起始地址赋值给p
fut(int * * s, int p[2][3]) {**s=p[1][1];}
参数s定义为类型int **即指向指针类型的指针 或者叫二级指针
用**s就是对其元素进行赋值
全部回答
- 1楼网友:神鬼未生
- 2021-01-22 16:35
enum weeks {sun, mon, tue, wed, thu, fri, sat}; //定义一个共用体weeks,成员为sun, mon, tue, wed, thu, fri, sat
enum weeks today; //定义一个weeks类型的变量today
enum response {no, yes, none}; //定义一个公用体response,成员为no, yes, none
enum response answer; //定义一个response类型的变量answer
today = tue; //today赋值为tue
answer = yes; //answer赋值为yes
if (answer == yes) printf("today is tuesday.\n"); //如果answer的值为yes,则输出“today is tuesday.”
else printf("today is not tuesday.\n");//否则输出"today is not tuesday."
我要举报
大家都在看
推荐资讯