C language Level Two pointer memory model ③

Source: Internet
Author: User

//Two-level pointer memory model ③#define_crt_secure_no_warnings#include<stdio.h>#include<stdlib.h>#include<string.h>//Detailed memory model//One-dimensional array type is typedef int MYARR[5]; Myarr A; (where Myarr is a one-dimensional array type)//Myarr *p;p is a pointer to a one-dimensional array//The type of pointer that is a one-dimensional array is a typedef int (*PARRTYPE) [5]; Parrtype p; (where parrtype is an array pointer type) p points to an array//p=&a;//typedef int (*PARRTYPE) [5]; Parrtype p; can be directly defined as int (*p) [5]; P is an array pointer, pointing to a typedef int MYARR[5]; an array of types//the step size of P is sizeof (int) *5=40 bytes//iterating through an arrayintPrintfarr (Char(*pin) [ -],intnum) {    intErro_msg =0; if(pin==NULL) {erro_msg=1; printf ("pin==null Erro msg:%d\n", erro_msg); returnerro_msg; }    inti =0; //Print Array//Note the step size of the pin is sizeof (char) *20 The pin+1 span is 20 bytes     for(i =0; i < num; i++) {printf ("%s\n", * (pin+i)); }    returnerro_msg;}voidMain () {Chartarr[3][ -] = {"AAA","BBB","CCC"}; //Tarr is essentially a pointer to a one-dimensional array whose type is typedef char (*PARRTYPE) [20]; The step size is sizeof (char) *20//variables of typedef char (*PARRTYPE) [20] type can be defined directly as char (*P) [+]Printfarr (Tarr,3); System ("Pause");}

C language Level Two pointer memory model ③

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.