Three memory models of level 2 pointers

Source: Internet
Author: User

Three memory models of level 2 pointers

/* Level tow point have three cache model */# include
 
  
# Include
  
   
Int Print (char ** pArr); int Print02 (char ** pArr, int num); int GetMem (char *** thirdModel, int len ); int Destory (char *** thirdModel, int len); int main () {int I = 0; char ** thirdModel = NULL; // first cache modelchar * firstModel [10] = {"abc", "linux", "unix", 0 }; // second cache modelchar secondModel [3] [10] = {"abc", "linux", "unix"}; // third cache modelGetMem (& thirdModel, 4 ); strcpy (* (thirdModel + 0), "abc"); strcpy (* (thirdModel + 1), "l Inux "); strcpy (* (thirdModel + 2)," unix "); printf (" firstModel start \ n "); Print (firstModel ); printf ("secondModel start \ n"); Print02 (secondModel, 4); printf ("thirdModel start \ n"); Print (thirdModel); Destory (& thirdModel, 4 ); return 0;} int Print (char ** pArr) {int ret = 0, I = 0; if (NULL = pArr) {ret =-1; printf ("arg is null error: % d \ n", ret); return ret;} while (* pArr) {printf ("% s \ n", * pArr ); ++ pArr;} return ret;} int Print02 (char ** pA Rr, int num) {int ret = 0, I = 0; // The second-level pointer is different from the pointer to the array. Char (* arr) [10] = pArr; if (NULL = pArr) {ret =-1; printf ("arg is null error: % d \ n ", ret); return ret;} for (I = 0; I
   
  
 

Related Article

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.