zoukankan      html  css  js  c++  java
  • [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 }
  • 相关阅读:
    C# 实现向指定邮箱发送信息功能
    asp.net webapi 解决跨域问题
    电脑通电自动开机设置
    C# 多个控件绑定一个事件
    C# DataGridView 标题栏背景颜色改变
    C# 输出csv文件后缀乱码
    C# textbox设定为只读后如何改变文本字体颜色
    C# 命名规则
    C# 傅里叶变换 逆变换 调用MathNet包
    使用SharpDevelop配合MonoGame进行游戏开发
  • 原文地址:https://www.cnblogs.com/little-monkey/p/7224760.html
Copyright © 2011-2022 走看看