CC Code Learning Note 1

Source: Internet
Author: User

#define#defineINT32 int #define INT8 Char #define CHAR Char#defineSshort signed short #define INT16 signed short#define_assert_str (z) _assert_tmp (z)#define_assert_tmp (z) #z//into a stringThe __file__ in the C language is used to indicate the name of the source file in C language of the bank statement where the __line__ is used to indicate the position information of the line statement in the source file __func__, which indicates the function #line to reset the value of the __line__ typedef ssize_t (*ZMSS_READLINKP) (Const Char*,Char*, size_t); ssize_t is a type typedef qtss_error (*QTSS_CALLBACKPROCPTR) (...);//declaring function pointer typestypedef qtss_error (*QTSS_CALLBACKPROCPTR) (...);//declaring a function pointer type, its type variable can be the function name is the function address, any parameter qtss_error return type. Strcpy#include<iostream>#include<stdlib.h>using namespacestd;voidMain () {intA =3;intb =4;intc = (b=a); cout<<"C:"<< c<<endl;//returns the assigned value 3System"Pause");}Char* STRCPY (Char* DES,Const Char*source) {Char* r=des; Assert (des! = NULL) && (Source! =NULL));  while((*des++ = *source++)! =' /'); returnR;} /*While ((*des++=*source++)); Explanation: The assignment expression returns the left operand, so after the assignment of NULL, the loop stops*/  while(*des++=*source++), equivalent to while(1){    *des = *source; if(*source = =' /') Break; SOURCE++; Des++;} strcat stitching function//Add the source string to const, indicating that it is an input parameterChar* STRCAT (Char* Strdest,Const Char*s Trsrc) {    //after the return address, it cannot be placed after the assert assertion to declare the address    Char* address=strdest; Assert ((strdest!=null) && (strsrc!=null));//add a non-0 assertion to the source address and destination address     while(*strdest)//is a simplified form of while (*strdest!= ')    {        //If you use while (*strdest++), an error occurs because strdest also executes once + + at the end of the loop,//then strdest will point to the next position of '/'. /So be in the loop body + +; Because to make *strdest last point//to the end of the string "\". strdest++; }      while(*strdest++=*strsrc++) {NULL;//the cycle condition can be used in + +,}//Here you can add statements *strdest= ' + '; no need    returnAddress//To implement chained operations, return the destination address}   Char*mystrcat (Char*DST,Const Char*SRC)//implement strcat functions in your own way   {       Char*P=DST;//the following action will change the destination pointer to point to, first define a pointer to record the DST        while(*dst!=' /') dst++;  while(*src!=' /') *dst++=*src++; *dst=' /'; returnP//DST now points to the last character after stitching, where it returns DST and an error occurs  } voidDelete () {if(Ptr! =NULL) Delete [] Ptr; Ptr=NULL; Len=0; }Char*Ptr;CharLastsourcechar = Ptr[len-1];stringStrreadbuf ("");

CC Code Learning Note 1

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.