Advertisement
cd62131

struct

Apr 27th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. typedef struct { char *name; int num; } eat_t;
  3. int main(void) {
  4.   eat_t eat[][2] = {
  5.     {{"もも" , 1}, {"みかん" , 2}},
  6.     {{"きゅうり" , 3}, { "ナス" , 4}}
  7.   };
  8.   int i, j;
  9.   for (i = 0; i < sizeof(eat) / sizeof(eat[0]); i++) {
  10.     for (j = 0; j < 2; j++) {
  11.       printf("%s: %d\n", eat[i][j].name, eat[i][j].num);
  12.     }
  13.     puts("");
  14.   }
  15.   return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement