栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

操作符详解2

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

操作符详解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;

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/629571.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号