All pastes #1624015 Raw Edit

Mine

public cpp v1 · immutable
#1624015 ·published 2009-10-16 18:27 UTC
rendered paste body
#include<stdio.h>#include<stdlib.h>      //include stdlib for malloc()//make nothing globalvoid fun(int**,int**);     /*pass double pointers so that changes made to them are visible outside fun()*/int main(void){    int s;    int *p1,*p2;    fun(&p1,&p2);       //Address of p1 & p2 must be passed as they are single pointers    s=*p1 + *p2;    printf("Sum= %d",s);    return 0;}void fun(int **dp1,int **dp2){    *dp1=malloc(sizeof(int));     //allocate memory to use it outside fun()    *dp2=malloc(sizeof(int));    **dp1=3;    **dp2=5;}