C language Multi-level pointers using __c language

Source: Internet
Author: User

Words not much said, direct code, the following is a multi-level pointer, through the pointer variable to modify the value of the variable


#include <stdio.h> #include <stdlib.h>


void Secondpoint (int **a, float ***f, double ****d, char *****c) {
**a = 100;
f = 9.2f;
D = 3.14;
c = ' g ';
}


int main () {
int a0 = 10;
int *a = &a0;

float F0 = 0.1f;
float *F1 = &f0;
float **F2 = &f1;

Double D0;
Double *d1 = &d0;
Double **d2 = &d1;
Double ***d3 = &d2;

char C0;
Char *c1 = &c0;
Char **c2 = &c1;
Char ***c3 = &c2;
Char ****c4 = &c3;

Secondpoint (&AMP;A,&AMP;F2,&AMP;D3,&AMP;C4);
printf ("a=%d,f=%.1f,d=%.2lf,c=%c\n", a0,f0,d0,c0);

System ("pause");
return 0;

}



It is important to note that the pointer variable is a pointer to a variable that cannot be stored, such as the following:

int *p = 10;

This type of writing is illegal in C because the pointer variable p is a pointer to a stored variable and cannot store a constant value




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.