Created
August 23, 2016 10:01
-
-
Save louisom/ff241a957d91e01b232fab5c44cb5ba0 to your computer and use it in GitHub Desktop.
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
/* | |
* This program coding from Expert C Programming. | |
* In page 214 "Play Around with Array/Pointer Arguments | |
* to show that C's array/pointer in arguemtns | |
*/ | |
#include <stdio.h> | |
char ga[] = "abcdefghijklmnopqrstuvwxyz"; | |
void func1(char ca[]) { | |
printf("&ca: \t\t%p\n", &ca); | |
printf("&(ca[0]): \t%p\n", &(ca[0])); | |
printf("&(ca[1]): \t%p\n", &(ca[1])); | |
} | |
void func2(char *pa) { | |
printf("&pa: \t\t%p\n", &pa); | |
printf("&(pa[0]): \t%p\n", &(pa[0])); | |
printf("&(pa[1]): \t%p\n", &(pa[1])); | |
printf("++pa: \t\t%p\n", ++pa); | |
} | |
int main() { | |
printf("&ga: \t\t%p\n", &ga); | |
printf("&(ga[0]): \t%p\n", &(ga[0])); | |
printf("&(ga[1]): \t%p\n", &(ga[1])); | |
func1(ga); | |
func2(ga); | |
printf("%s\n", ga); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment