Print the address value pointed to by the pointer

Source: Internet
Author: User

Put the error code directly:

static void print_cpu_src(uint8_t * src,int stride){    int i,j;    printf("Magnum  cpu src addr == %p, stride ==%d:\n",&src,stride);     for (i = 0; i < 11; ++i) {             printf("\n");            for (j =0; j < 4; ++j) {                          printf("%d ,", src[j]);            }            src +=  stride;            printf("new src addr %p\n",&src);          }     printf("\n");}
View code

Output result:

Magnum cpu src addr = 000000000022f4c0, stride = 800:

129,124,122,124, new src addr 2017100000022f4c0

130,125,122,125, new src addr 2017100000022f4c0

132,125,123,125, new src addr 2017100000022f4c0

132,126,123,125, new src addr 2017100000022f4c0

151,127,124,126, new src addr 2017100000022f4c0

151,127,125,126, new src addr 2017100000022f4c0

153,128,125,127, new src addr 2017100000022f4c0

154,128,125,127, new src addr 2017100000022f4c0

157,129,125,127, new src addr 2017100000022f4c0

158,129,125,127, new src addr 2017100000022f4c0

161,130,125,128, new src addr 2017100000022f4c0

The output address values are the same. Naturally, the output address value is the address value of the pointer variable. The pointer variable is the memory address that has not changed.

Modify the new Code as follows:

static void print_cpu_src(uint8_t * src,int stride){    int i,j;    printf("Magnum  cpu src addr == %p, stride ==%d:\n",(int)src,stride);     for (i = 0; i < 11; ++i) {             printf("\n");            for (j =0; j < 4; ++j) {                          printf("%d ,", src[j]);            }            src +=  stride;            printf("new src addr %p\n",(int)src);          }     printf("\n");}
View code

Summary:

In fact, the pointer * SRC, SRC is the address value pointed to, just print it directly

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.