C what % symbol to access arrays? -


i'm trying access single row of multidimensional array. however, keep getting following error message: format specifies type 'int' argument has type 'int *'. assume it's saying there's particular format arrays; symbol use access them if not %i?

#include <stdio.h>  int main(void) {      int matrix1[5][4] =         {{1,2,3,4},         {5,6,7,8},         {9,10,11,12},         {13,14,15,16},         {17,18,19,20}};      printf ("%i",matrix1[0]);       return 0; } 

you accessing first row of array converted type int * that's reason of compiler's message.

if want print whole row can try with

int i; (i = 0 ; < 4 ; ++i)     printf("%d ", matrix1[0][i]);     /*                       ^ index specify integer array */ printf("\n"); 

if want first row , first column of array try

printf("%d\n", matrix1[0][0]); 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -