Sun Jun 18 10:56:00 UTC 2023 inscode

上级 5a5142f8
#include<stdio.h>
#include<stdlib.h>
void fun(int*p1,int*p2,int*s){
s = (int*)malloc(sizeof(int));
printf("%d\n",s);
*s = *p1 + *(p2++);
}
int main(){
int a[2] = {1,2},
b[2] = {10,20},
*s = a;
printf("%d\n",s);
fun(a,b,s);
printf("%d\n",*s);
}
#include<stdio.h>
#include<stdlib.h>
// 定义了一个函数,该函数接收两个指针变量和一个指向整数变量的指针作为参数
void fun(int*p1,int*p2,int*s){
// 动态分配内存
s = (int*)malloc(sizeof(int));
printf("%d\n",s); // 打印分配内存的地址
*s = *p1 + *(p2++); // 计算两个整数变量的和并存储在动态分配的内存中
}
int main(){
int a[2] = {1,2}, // 定义一个包含两个整数的数组a
b[2] = {10,20}, // 定义一个包含两个整数的数组b
*s = a; // 定义一个指向整数的指针变量s,并将它初始化为数组a的首地址
printf("%d\n",s); // 打印数组a的首地址
// 调用fun函数,传递数组a、b和指针s的值
fun(a,b,s);
// 打印指针s指向的内存中的值
printf("%d\n",*s);
#include <stdio.h>
int main(int argc, char **argv) {
int a = 4,b=5,c=0,d;
d = !a && !b||!c;
printf("%d\n",d);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册