*** 作符详解2

 *** 作符详解2,第1张

*** 作符详解2

+=

-=

*=

/=

%=

>>=

<<=

&=

|=

^=

 

 

 

 

 sizeof

&:取地址 *** 作

*:解引用 *** 作符

(类型):(强制类型转换) 

 

#include 
void test1(int arr[])
{
 printf("%dn", sizeof(arr));//(2)
}
void test2(char ch[])
{
 printf("%dn", sizeof(ch));//(4)
}
int main()
{
 int arr[10] = {0};
 char ch[10] = {0};
 printf("%dn", sizeof(arr));//(1)
 printf("%dn", sizeof(ch));//(3)
 test1(arr);
 test2(ch);
 return 0;
}

 

 

 

 

 

 

   i为真时就不用算了

 

 

 

 

 

2.( ) 函数调用 *** 作符

接受一个或者多个 *** 作数:第一个 *** 作数是函数名,剩余的 *** 作数就是传递给函数的参数。 

 

#include 
 void test1()
 {
 printf("hehen");
 }
 void test2(const char *str)
 {
 printf("%sn", str);
 }
 int main()
 {
 test1();            //实用()作为函数调用 *** 作符。
 test2("hello bit.");//实用()作为函数调用 *** 作符。
 return 0;
 }

 

 

#include 
struct Stu
{
 char name[10];
 int age;
 char sex[5];
 double score;
};
void set_age1(struct Stu stu)
{
 stu.age = 18;
}
void set_age2(struct Stu* pStu)
{
 pStu->age = 18;//结构成员访问
}
int main()
{
 struct Stu stu;
 struct Stu* pStu = &stu;//结构成员访问
 
 stu.age = 20;//结构成员访问
 set_age1(stu);
 
 pStu->age = 20;//结构成员访问
 set_age2(pStu);
 return 0;

 

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5635453.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存