All pastes #77145 Raw Edit

Unnamed

public c v1 · immutable
·published 2006-07-02 18:08 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=1; i < j; i++)       {          p[i] = (char *) malloc(sizeof(char *) * j);               }            }void del_array(char **p)  {     int i=0;       for (i=0; i < n; i++)       delete []p[i] ;     delete []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+j)+i));        printf("\n");       }//     printf("%c", *(*(p+1)+1) );         return 0;  }void test(char **p)  {       *(*(p+1)+1) = 1;  }int main()  {     char *p;     new_array(&p,n);     test(&p);     print(&p);     del_array(&p);             getchar();     return 0 ;  }