Created
November 24, 2014 18:25
-
-
Save matason/28ba84db6ebca831187d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
char * cards [2] [2] = {"0000", "1000", "0111", "1111"}; | |
int main () | |
{ | |
printf("Address of cards is %p\n", &cards); | |
printf("Which can also be written %p\n", cards[0]); | |
// Iterate over rows and cols of cards. | |
int row, col; | |
for (row = 0; row <= 1; row++) | |
{ | |
for (col = 0; col <= 1; col++) | |
{ | |
printf("Card at [%d][%d] is %s\n", row, col, *(cards[row] + col)); | |
} | |
} | |
// Alternatively, print using pointer arithematics. | |
int x; | |
for (x = 0; x <= 3; x++) | |
{ | |
printf("%s\n", *(cards[0] + x)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment