0
点赞
收藏
分享

微信扫一扫

20241009_233117 c语言 利用指针处理其它函数中的数据

#include <stdio.h>  
#include <stdlib.h>
#include <time.h>

void swap(int* p1,int* p2);

int main() {
	int a = 1;
	int b = 2;
	printf("%d,%d\n",a,b);
	swap(&a,&b);
	printf("%d,%d\n",a,b);
    return 0;  
}

void swap(int* p1,int* p2){
	int temp = *p1;
	*p1 = *p2;
	*p2 = temp;
}

举报

相关推荐

0 条评论