C++函数方法整理

1.如何计算基本数据类型的数据范围

#include <iostream.h> 

int main()

    unsigned int i = -1; 
    cout << i << endl;

    return 0;
}
其它的也可以类似得出。除以二就是int类型最大正数值。

不需要知道字节数
或者

 

int main()

{
    int m = 0; 
    printf("max = %u,",~m);

    return 0;

}

2.将整型转化为二进制表示的三种方法:
方法1:

C/C++ code
     
     
int n; cin >> n; bitset < 8 > ibs(n); cout << ibs << endl;


方法2:

C/C++ code
     
     
int getTwo( int n) { int num[ 32 ]; const int MAX = sizeof ( int ) * 8 ; for ( int i = 0 ; i < MAX; i ++ ) { if ((n >> i) & 0x01 == 1 ) { num[i] = 1 ; } else { num[i] = 0 ; } } for (i = MAX - 1 ; i !=- 1 ; -- i) { cout << num[i]; } return count; }


方法3:
void trans(int n)
{
    int x;
    x=n%2;
    n=n/2;
    if(n!=0)
    { 
        trans(n);
    }
    switch(x)
    { 
        case 10:cout < < 'a';break; 
        case 11:cout < < 'b';break; 
        case 12:cout < < 'c';break; 
        case 13:cout < < 'd';break; 
        default :cout < <x;
    }
}

 

3.Rundll32.EXE d:/hacker.dll dllmain

这一句画的意思是把d:/hacker.dll注入到RUNDLL32.EXE里,执行输出函数:DLLMAIN

 

4.自定义函数入口
#pragma comment(linker, "/ENTRY:EntryPoint")

void EntryPoint()
{   
   
int nRet = WinMain(GetModuleHandle(NULL),
              NULL,
              GetCommandLine(),
              SW_SHOWNORMAL);
              ExitProcess(nRet);
}

int WINAPI WinMain(HINSTANCE hInstance,      // handle to current instance
           HINSTANCE hPrevInstance,  // handle to previous instance
           LPSTR lpCmdLine,          // command line
           int nCmdShow              // show state
           )
{   
      
//
       return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值