Common C_c ++ code

Source: Internet
Author: User

# Include <iostream>
# Include <time. h>
Int main ()
{
Time_t curtime = time (0 );
TM Tim = * localtime (& curtime );
Int day, Mon, year;
Day = Tim. tm_mday;
MON = Tim. tm_mon;
Year = Tim. tm_year;

STD: cout <year + 1900 <"year" <mon + 1 <"month" <day <"day" <STD: Endl;

System ("pause ");
Return 0;

}

//// Process the input parameters with an indefinite length, which is generally used to print logs.

Writelog (char * format ,...)

{

Va_list ARGs;

Char Buf [4096];

Memset (BUF, 0,4096 );

Va_start (ARGs, format );

Vsprintf_s (& Buf [strlen (BUF)], 4096, format, argS );

Va_end (ARGs );

String strresult (BUF );

... // Perform other operations as follows

}

//// A and B mutual references

//// In the. h file:

Class B; // note that a. h cannot contain B. H.

....

Void fun (B * pb );

//// End of a. h

//// A. cpp file:

# Include "B. H"

Void fun (B * pb)

{....};

... // End of A. cpp

///// In the B. H file

# Include "A. H"

A * m_pa;

.....

//// End of B. H

///// In the B. cpp File

# Include "B. H"

....

M_pa = xxxx;

//// // End of B. cpp

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.