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;
}