C language-06 complex data types-03 pointers

Source: Internet
Author: User

Definition of pointer variable

Variable type * variable name;

#include <stdio.h>int  main () {    //  pointer is a function: can access the corresponding storage space    according to an address value // int before pointer variable p: Pointer variable p can only point to data    of type int int // defines a pointer variable p
int - ; p = &A; //pointer variable p points to variable a pointer variable can only store address
    ten;  // the * differs from the * when defining a pointer variable, which represents access to the corresponding storage space     - ;        printf ("%d\n", *p);        return 0 ;}
Practice
//modify external variables within a function based on the pointer#include <stdio.h>voidChangeint*p);intMain () {intA =Ten; Change (&a); printf ("a=%d\n", a); return 0;}voidChangeint*p) {    *p = -;}

//using pointers to let functions indirectly have multiple return values#include <stdio.h>intMain () {intA = the; intb =Ten; intHe=0, cha=0; Test (A, B,&he,&cha); printf ("and is%d, the difference is%d", He,cha);}voidTestintAintBint(CNint*d) {    *c = A +b; *d = Ab;}

C language-06 complex data types-03 pointers

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.