[c/c++] programming之路(9)、运算优先级

一、运算优先级

[c/c++] programming之路(9)、运算优先级

二、条件运算符(表达式1?表达式2:表达式3)

当式1正确时,取式2的值;否则,取式3的值

[c/c++] programming之路(9)、运算优先级

三、格式字符

[c/c++] programming之路(9)、运算优先级

 #include<stdio.h>
#include<stdlib.h> void main(){
int num;
scanf("%d",&num);
printf("\n%d",num);
printf("\n%ld",num);
printf("\n%10d",num);//10位靠右
printf("\n%-10d",num);//10位靠左
printf("\n%010d",num);//10位,左边补0
printf("\n%5d",num);//5位,超过按照实际,不超过则靠右 system("pause");
}

[c/c++] programming之路(9)、运算优先级

 #include<stdio.h>
#include<stdlib.h> void main(){
int num;
char str0[],str[];
scanf("%d%s",&num,str0);
printf("num=%d,str0=%s",num,str0);
sprintf(str,"for /l %%i in (1,1,%d) do %s",num,str0);
system(str); system("pause");
}

[c/c++] programming之路(9)、运算优先级

打开3个计算器

四、跨过权限修改值(注射)

 #include<stdio.h>
#include<windows.h> void main(){
int x=;
int y=;
printf("%x,%x",&x,&y);
while(){
printf("\n阿飞有%d个妞,有%d元",x,y);
Sleep();
}
}

[c/c++] programming之路(9)、运算优先级

根据地址,编写代码,生成dll文件,进行注射

 _declspec(dllexport) void go(){
int *p=(int *)0x4dfcbc;
int *q;
*p=;
q=(int *)0x4dfcb0;
*q=;
}

[c/c++] programming之路(9)、运算优先级

[c/c++] programming之路(9)、运算优先级

五、字符串赋值

 #include<stdio.h>
#include<stdlib.h> void main(){
char str[],strurl[];
scanf("%s",str);
sprintf(strurl,"%s",str);//实现字符串的赋值,因为字符串不能通过 str=strurl 赋值
sprintf(strurl,"%.7s",str);//截取前面7个字符
sprintf(strurl,"%10.7s",str);//10位宽,截取前面7个字符
system(strurl);
system("pause");
}
上一篇:痞子衡嵌入式:微控制器CPU性能测试基准(EEMBC-CoreMark)


下一篇:nfs+keepalived高可用