c語(yǔ)言指針的學(xué)習(xí)心得
main()
{
view *有求于人;
if(真的做不到)
{
point *怎么辦?
怎么辦?=&可以去找比自己犀利的人尋求;
}
else(做的到&&但是自己不想努力去做)
{
result *怎么辦?
怎么辦?=&悲??;
}
有求于人=怎么辦;
printf(“有求于人=%chinese”,有求于人);
}
人生道路慢慢曲折,想得到穩(wěn)定的發(fā)展和提高,要時(shí)刻思考,如果他不在我身邊怎么辦,多多去尋找自己解決問(wèn)題的途徑。指針在傳遞過(guò)程,是全傳遞,而實(shí)參傳遞是部分傳遞。
#include
main()
{
int a,b;
int*p1,*p2;
a=1;b=3;
// scanf("%d,%d",&a,&b);
p1=&a;p2=&b;
if(aswap(p1,p2);
printf("%d,%d",a,b);
}
swap(int *pa,int *pb)
{
int p;
p=*pa;
*pa=*pb;
*pb=p;
}
--------------------------------------------------------------
筆記2:指針函數(shù)
#include
main()
{
int a,b,c;
int max(a,b);
int (*p)(a,b);
p=&max;
scanf("%d%d",&a,&b);
c=(*p)(a,b);
printf("max=%d",c);
while(1);
}
max(a,b)
{
if(a>b)
{
return a;
}
else
{
return b;
}
}
-------------------------------------------------------------------------------------------------
筆記3:多維數(shù)組乃一維之嵌套。
筆記4:結(jié)構(gòu)體指針。
main()
{ struct student
{ long int num;
char name[20];
char ***;
float score;
}stu_1,*p;
p=&stu_1;
stu_1.num=89757;
strcpy(stu_1.name,"Li Lin");
p->***=‘M‘;
p->score=89.5;
printf("No:%ldname:%s***:%cscore:%f",
(*p).num , p->name , stu_1.*** , p->score );
}
筆記5:較難理解的部分,結(jié)構(gòu)化指針整體使用
#include
struct complex add(struct complex,struct complex);
struct complex
{
double re;//實(shí)部
double im;//虛部
};
struct complex add(struct complex a,struct complex b)
{
struct complex c;
c.re=a.re+b.re;
c.im=a.im+b.im;
return c;
}
int main()
{
struct complex x={6.5,8.9},y={7.1,9.4};
struct complex z;
z=add(x,y);
printf("和為:%5.2lf+i%5.2lf",z.re,z.im);
}
/*#include
struct student
{
int num;
char *name;
char ***;
float score;
}stu={1,"張賓",F,55},*pstu;
int main()
{
pstu=&stu;
printf("學(xué)號(hào):%d 姓名:%s",stu.num,stu.name);
printf("性別:%c 成績(jī):%5.2f",stu.***,stu.score);
printf("學(xué)號(hào):%d 姓名:%s",(*pstu).num,(*pstu).name);
printf("性別:%c 成績(jī):%5.2f",(*pstu).***,(*pstu).score);
printf("學(xué)號(hào):%d 姓名:%s",pstu->num,pstu->name);
printf("性別:%c 成績(jī):%5.2f",pstu->***,pstu->score);
while(1);
}
*/
評(píng)論