# C 的入门者请进，否则不要花时间click

//只需要把下面代码paste到new project, run, 即看到效果
//The goal of this program is to show:
// the relationship of Pointer and Address in C languange.

//created by Feb 4th, 2002
//modified by Feb 4th,2004

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

//if put   3, result=3^3+3=12;
//if       4, result=4^4+4=20...
double squarePlus(int a,double *b);

int main(void)
{
double x=3,y=3,result=0;
printf("/n 0.....y Address = %p/n",&y); // print y address

//scanf(y);
result=squarePlus(3,&y);

printf("/n SquarePlus of %f = %2.0f /n",x,result);

return 0;
}
/*

0.....y Address = 0012FF70
2.....double value(*b) = 3.000000
...processing: (*b) *= *b;

SquarePlus of 3.000000 = 12
Press any key to continue

*/

//**********************************************************//
double squarePlus(int a,double *b)
{
//Print the address of pointer:
printf(" 1.....pAddress(b) = %p /n",b);

//Print the value after calcuation:
printf(" 2.....double value(*b) = %f/n",*b);

//Save before you have to change.
double k = *b;
//b=&k; //[YES] if b= sth's address;
//        *b= sth's value;

// b is always the Result:
*b=a;
(*b) *= *b;                 //multipile itself
printf("...processing: (*b) *= *b;/n");

*b=*b+k;        //[YES] value itself +1;
//b=b+b;        //[NO]  just make "b" to another address;

return *b;
//return (*b)*(*b)+(*b);  //[YES] works also
//return b;      // [NO] cannot convert from 'double *' to 'double'
}

//http://www.eurasia.edu/bbs/ti_view.asp?FN_id=15&FC_root_id=115073&FC_id=115073

• 0
点赞
• 0
收藏
• 打赏
• 0
评论
04-11 1万+
10-22 886
01-01 886
12-10 43
11-30 430
10-14 85
10-16 600
12-09 604
07-18 398
03-01 215
10-07 725
08-29 536
08-07 256
05-08 172
06-02 390
08-21 4110

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

©️2022 CSDN 皮肤主题：大白 设计师：CSDN官方博客

wwtmw

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。