Last active
March 14, 2017 04:28
-
-
Save jacyzon/daf738a410dcf7ef4f5e to your computer and use it in GitHub Desktop.
Welcome to Pointer Hell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ===================================================================================== | |
* | |
* Filename: pointer_hell.c | |
* | |
* Description: Welcome to Pointer Hell | |
* | |
* Version: 1.0 | |
* Created: 10/27/2015 12:04:36 AM | |
* Revision: none | |
* Compiler: gcc | |
* | |
* Author: jacyzon | |
* | |
* ===================================================================================== | |
*/ | |
#include <stdio.h> | |
void SizeofB(unsigned int (*B)[5]){ | |
printf("B[0] -> %u\n", B[0]); | |
printf("B[1] -> %u\n", B[1]); | |
printf("B[2] -> %u\n\n", B[2]); | |
printf("B[0][0] -> %u\n", B[0][0]); | |
printf("B[0][1] -> %u\n", B[0][1]); | |
printf("B[0][2] -> %u\n\n", B[0][2]); | |
printf("*B -> %u\n", *B); | |
printf("*B+1 -> %u\n", *B+1); | |
printf("*B+2 -> %u\n\n", *B+2); | |
printf("**B -> %u\n", **B); | |
printf("**B+1 -> %u\n", **B+1); | |
printf("**B+2 -> %u\n\n", **B+2); | |
} | |
void SizeofA(unsigned int *A){ | |
printf("A[0] -> %u\n", A[0]); | |
printf("A[1] -> %u\n\n", A[1]); | |
printf("(&A) -> %u\n", (&A)); | |
printf("(A) -> %u\n", (A)); | |
printf("(A+1) -> %u\n", (A+1)); | |
printf("sizeof A -> %u\n", sizeof(A)); | |
printf("sizeof *A -> %u\n\n", sizeof(*A)); | |
} | |
int main( void ){ | |
unsigned int M[5] = {0, 2, 4, 6, 8}; | |
printf("*M -> %u\n", *M); | |
printf("*M+1 -> %u\n", *M+1); | |
printf("*M+2 -> %u\n\n", *M+2); | |
printf("M -> %u\n", M); | |
printf("&M -> %u\n\n", &M); | |
printf("sizeof M -> %u\n", sizeof(M)); | |
printf("sizeof &M -> %u\n", sizeof(&M)); | |
printf("sizeof *M -> %u\n\n", sizeof(*M)); | |
printf("M -> %u\n", M); | |
printf("M+1 -> %u\n", M+1); | |
printf("M+2 -> %u\n\n", M+2); | |
printf("&M -> %u\n", &M); | |
printf("&M+1 -> %u\n", &M+1); | |
printf("&M+1 -> %u\n\n", &M+2); | |
SizeofA(M); | |
SizeofB(&M); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment