[ create a new paste ] login | about

Link: http://codepad.org/BIEghARe    [ raw code | output | fork ]

C, pasted on Mar 4:
#include<stdio.h>
#define ROW 10
#define COL 5
typedef struct {
 int a;
 char b;
} structX;
void to(structX (*ptr2D)[ROW][COL], int r, int c){
 printf("in to: %d %c\n", (*ptr2D)[r][c].a, (*ptr2D)[r][c].b);
}
int main(){
 structX matrix[ROW][COL];
 structX (*ptr2D)[ROW][COL];
 ptr2D = &matrix;
 structX  i;
 i.a = 5; 
 i.b = 'a';
 int r = 3;
 int c = 2;
 (*ptr2D)[r][c] = i;

 if((*ptr2D)[r][c]);
 
 printf("%d %c\n", (*ptr2D)[r][c].a, (*ptr2D)[r][c].b);
 to(&matrix, r, c);
}


Output:
1
2
In function 'main':
Line 22: error: used struct type value where scalar is required


Create a new paste based on this one


Comments: