Skip to content

Instantly share code, notes, and snippets.

@matason
Created November 24, 2014 18:25
Show Gist options
  • Save matason/28ba84db6ebca831187d to your computer and use it in GitHub Desktop.
Save matason/28ba84db6ebca831187d to your computer and use it in GitHub Desktop.
#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