Code:int main() { int matrix[2][4] = { { 11, 22, 33, 99}, { 44, 55, 66, 110}, }; int **ptr = (int **) matrix; printf(" %d ", **ptr) ; return 0; } The above pgm didn't give any result while I compile. Please explain it.
Code:int main() { int matrix[2][4] = { { 11, 22, 33, 99}, { 44, 55, 66, 110}, }; int **ptr = (int **) matrix; printf(" %d ", **ptr) ; return 0; } The above pgm didn't give any result while I compile. Please explain it.
What do you mean by "didn't give any result while I compile". Do you mean you didn't get an executable? Or do you mean that you got an executable but you got no output? (In this case, your output is probably hiding in the front of your command prompt, since you didn't print a blank line after it.)
Hey!
Firstly you need to allocate memory for the values. And this is bot the right way to work with with 2 dimensional arrays.
Read Dynamic allocation of memory!
something like
Something like this
cheersCode:r dimension n rows, J columns ///allocate memory for r[i][j], id[i], read2hap[i] r = (short unsigned int**)calloc(n, sizeof(unsigned short int*)); if (r == NULL) exit(EXIT_FAILURE); for (i = 0; i < n; i++){ r[i] = (unsigned short int*)calloc(J, sizeof(unsigned short int)); }
Last edited by satty; 12-07-2010 at 11:17 AM.
You Should not ignore warning; but, learn to fix the causes.Code:int main() { int matrix[2][4] = { { 11, 22, 33, 99}, { 44, 55, 66, 110}, }; int *ptr = &matrix[0][0]; int **pptr = &ptr; printf(" %d ", **pptr) ; return 0; }
Doing manual cast to remove the warnings IS NOT the first thing to try!
Tim S.