码迷,mamicode.com
首页 > 其他好文 > 详细

C原始指针2--创建交换值函数进一步理解

时间:2020-12-02 12:36:50      阅读:8      评论:0      收藏:0      [点我收藏+]

标签:函数   code   技术   mamicode   color   kkk   main   理解   int   

 1 #include <stdio.h>
 2 int k = 222, t = 9;
 3 void swap(int *a, int *b);
 4 
 5 main() {
 6      swap(&k, &t);
 7      printf("\nkkkkkk=%d\nttttttttt=%d", k, t);
 8 }
 9 
10 void swap(int *A, int *B) {
11      int s = *A;
12      printf("s=%d\tA=%d\tB=%d\n", s, *A, *B);
13      *A = *B;//在B所指的地址取值,通过A传入A所指地址
14      printf("s=%d\tA=%d\tB=%d\n", s, *A, *B);
15      *B = s;
16      printf("s=%d\tA=%d\tB=%d", s, *A, *B);
17 
18 }

输出技术图片

 

C原始指针2--创建交换值函数进一步理解

标签:函数   code   技术   mamicode   color   kkk   main   理解   int   

原文地址:https://www.cnblogs.com/impw/p/14051563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!