Új hozzászólás Aktív témák

  • Jester01

    veterán

    válasz [HUN]Zolee #132 üzenetére

    t.c: In function ‘test’:
    t.c:40: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int *’
    t.c:41: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int *’

    Valamint a foglalás valóban rossz, ha már egyszer int-eket akarsz tárolni, akkor azoknak foglalj helyet, illetve ügyelj a pointerekre!

    Diff:

    --- t.c.orig 2007-11-20 16:48:48.000000000 +0100
    +++ t.c 2007-11-20 16:59:32.000000000 +0100
    @@ -8,24 +8,24 @@
    int i,j;


    - (*t)=(int***)malloc(sor*sizeof(char));
    + (*t)=(int***)malloc(sor*sizeof(int**));

    for (i=0;i<sor;i++) {
    - (*t)[i]=(int**)malloc(sor*sizeof(char));
    + (*t)[i]=(int**)malloc(sor*sizeof(int*));
    }

    for(i=0;i<sor;i++){
    for (j=0;j<sor;j++){
    printf("i:%d j:%d\n",i,j);
    - (*t)[i][j]=(int*)malloc(2*sizeof(char));
    + (*t)[i][j]=(int*)malloc(2*sizeof(int));
    }
    }

    for (i=0;i<sor;i++){
    for (j=0;j<sor;j++) {

    - t[i][j][0]=0;
    - t[i][j][1]=0;
    + (*t)[i][j][0]=0;
    + (*t)[i][j][1]=0;
    }
    }

    @@ -37,8 +37,8 @@

    for (i=0;i<sor;i++) {
    for (j=0;j<sor;j++) {
    - printf("%d",t[i][j][0]);
    - printf("%d",t[i][j][1]);
    + printf("%d",(*t)[i][j][0]);
    + printf("%d",(*t)[i][j][1]);
    }
    printf("\n");
    }

    Jester

Új hozzászólás Aktív témák