All pastes #77114 Raw Edit

Anonymous

public c v1 · immutable
·published 2006-07-02 17:17 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#define n 5  void new_array(char **p, int j)  {     int i=0;     *p = (char *) malloc(sizeof(char *) * j);     for (i=0; i < j; i++)        p[i] = (char *) malloc(sizeof(char *) * j);  }void del_array(char **p)  {     int i=0;       for (i=0; i < n; i++)       free(p[i]);     free(p);  }   int print(char **p)  {     int i=0, j=0;     for (i=0; i < n; i++)       {        for (j=0; j < n; j++)           printf("%c", p[i][j]);        printf("\n");       }  }void test(char **p) {     p[1][0] = 'a'; }int main()  {     char *p;     new_array(&p,n);     test(&p);     del_array(&p);             return 0 ;  }