I have been trying for hours to create a specific prototype program that determines a pascal's triangle for a give number of rows. However, prototype must have the return type of int**. I just recently learnt about pointers and I would really appreciate it if anyone could give me a hint as to why my attempt of the function doesn't work.
As well, i am not sure how I can check if my return value actually points to the pascal triangle.
Code:
#include <stdio.h>
#include <stdlib.h>
int **getPascalTriangle(int n)
{
int i, j, value;
int *c;
int ** pp;
int k, gap;
c=(int*)malloc(n*sizeof(int));
printf("\n");
gap=n;
for(i=0;i<=n-1;i++)
{ value=1;
for(k=gap;k>=0;k--)
printf(" ");
gap--;
for(j=0;j<=i;j++)
{
c=&value;
value=(*c*(i-j)/(j+1));
}
printf("\n");
}
*pp=c;
return pp;
}
int main(void)
{
int n;
printf("Please enter value for number of rows in PAscal's triangle:");
scanf("%d",&n);
getPascalTriangle(n);
return 0;
}