Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
332 B
4
Indexable
Never
int matrixMemoryAllocate(int*** matrix, int rows, int cols){
    
    int i;
    *matrix = (int**) malloc(sizeof(int*) * rows);
    
    if (*matrix == NULL) return 0;
    
    for (i = 0; i < rows; i++){
        (*matrix)[i] = (int*) malloc(sizeof(int) * cols);
        if((*matrix)[i] == NULL) return 0;
    }
    
    return 1;
}