C ++ Function Methods

Source: Internet
Author: User

1. How to calculate the data range of the basic data type

# Include <iostream. h>

Int main ()
{
Unsigned int I =-1;
Cout <I <Endl;

Return 0;
}
Others can be obtained similarly. Divide by two to be the largest positive value of the int type.
No need to know the number of bytes
Or

 

Int main ()

{
Int m = 0;
Printf ("max = % u ,",~ M );

Return 0;

}

2. Three Methods to convert an integer into a binary representation:
Method 1:

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

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

Method 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

This sentence refers to injecting D:/hacker. DLL into rundll32.exe and executing the output function: dllmain

 

4. User-Defined Function entry
# Pragma comment (linker, "/entry: entrypoint ")

Void entrypoint ()
{
Int nret = winmain (getmodulehandle (null ),
Null,
Getcommandline (),
Sw_shownormal );
Exitprocess (nret );
}

Int winapi winmain (hinstance, // handle to current instance
Hinstance hprevinstance, // handle to previous instance
Lpstr lpcmdline, // command line
Int ncmdshow // show state
)
{
//
Return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.