// demo1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
int i ;
void ch (int* a, int* b){
int p ;
p = *a ;
*a = *b ;
*b = p ;
}
int main()
{
int i = 3 ;
int j = 5 ;
ch(&i,&j) ;
printf("%d\n",i ) ;
return 0;
}
本文通过一个简单的C++程序演示了如何使用指针来交换两个整数变量的值。程序首先定义了一个用于交换值的函数,然后在主函数中创建了两个整数变量并调用了该函数进行值交换,最后输出交换后的结果。
28万+

被折叠的 条评论
为什么被折叠?



