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


    一、运算优先级

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

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

    三、格式字符

     1 #include<stdio.h> 
     2 #include<stdlib.h> 
     3 
     4 void main(){
     5     int num;
     6     scanf("%d",&num);
     7     printf("
    %d",num);
     8     printf("
    %ld",num);
     9     printf("
    %10d",num);//10位靠右
    10     printf("
    %-10d",num);//10位靠左
    11     printf("
    %010d",num);//10位,左边补0
    12     printf("
    %5d",num);//5位,超过按照实际,不超过则靠右
    13 
    14     system("pause");
    15 }

     1 #include<stdio.h> 
     2 #include<stdlib.h> 
     3 
     4 void main(){
     5     int num;
     6     char str0[30],str[50];
     7     scanf("%d%s",&num,str0);
     8     printf("num=%d,str0=%s",num,str0);
     9     sprintf(str,"for /l %%i in (1,1,%d) do %s",num,str0);
    10     system(str);
    11 
    12     system("pause");
    13 }

    打开3个计算器

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

     1 #include<stdio.h>
     2 #include<windows.h>
     3 
     4 void main(){
     5     int x=10;
     6     int y=100000;
     7     printf("%x,%x",&x,&y);
     8     while(1){
     9         printf("
    阿飞有%d个妞,有%d元",x,y);
    10         Sleep(1000);
    11     }
    12 }

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

    1 _declspec(dllexport) void go(){
    2     int *p=(int *)0x4dfcbc;
    3     int *q;
    4     *p=0;
    5     q=(int *)0x4dfcb0;
    6     *q=100;
    7 }

    五、字符串赋值

     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 
     4 void main(){
     5     char str[50],strurl[50];
     6     scanf("%s",str);
     7     sprintf(strurl,"%s",str);//实现字符串的赋值,因为字符串不能通过 str=strurl 赋值
     8     sprintf(strurl,"%.7s",str);//截取前面7个字符
     9     sprintf(strurl,"%10.7s",str);//10位宽,截取前面7个字符
    10     system(strurl);
    11     system("pause");
    12 }
  • 相关阅读:
    模式的作用就是解耦,解耦,再解耦,让事情变简单、可控制。
    系统的同构性分析
    “以客观事物(object)的形式来组织程序”
    String的indexOf()的三种情况
    关于finally关键字
    openSession和getCurrentSession的区别?
    eclipse括号跳转
    final修饰的类能不能创建一个对象
    使用svn从恢复到某个版本的时候会报错
    关于TableModel的中获取表格数据的问题
  • 原文地址:https://www.cnblogs.com/little-monkey/p/7224760.html
Copyright © 2020-2023  润新知