Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does (int (*)[])var1 stand for?

I found this example code and I tried to google what (int (*)[])var1 could stand for, but I got no usefull results.

#include <unistd.h>
#include <stdlib.h>

int i(int n,int m,int var1[n][m]) {
    return var1[0][0];
}

int example() {
    int *var1 = malloc(100);
    return i(10,10,(int (*)[])var1);
} 

Normally I work with VLAs in C99 so I am used to:

#include <unistd.h>
#include <stdlib.h>

int i(int n,int m,int var1[n][m]) {
    return var1[0][0];
}

int example() {
    int var1[10][10];
    return i(10,10,var1);
} 

Thanks!

like image 279
Framester Avatar asked Jun 04 '10 09:06

Framester


1 Answers

It means "cast var1 into pointer to array of int".

like image 93
Michael Madsen Avatar answered Oct 02 '22 22:10

Michael Madsen