[ create a new paste ] login | about

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

C, pasted on Mar 24:
#include <stdio.h>
#define size1 5
#define size2 10
int main(){
    int i,j,k=0;
    int **mem=malloc(5, sizeof(int*));
    for(i=0;i<size1;i++){
        mem[i]=malloc(10, sizeof(int));
    }
    
    for(i=0;i<size1;i++){
        for(j=0;j<size2;j++){
            mem[i][j]=k;
            k++;
            printf("%d",mem[i][j]);
            if(k%10==0){
                printf("\n");
            }
        }
    }
    
    for(i=0;i<size1;i++){
        free(mem[i]);
    }
    free(mem);
    return 0;
}


Output:
1
2
3
4
In function 'main':
Line 6: warning: incompatible implicit declaration of built-in function 'malloc'
Line 6: error: too many arguments to function 'malloc'
Line 8: error: too many arguments to function 'malloc'


Create a new paste based on this one


Comments: