amicable number program bus error

#include<stdio.h>
struct amicable
{
int **amicablepair;
int size;
};
struct amicable *getAmicablePairs(int startnum, int endnum);
int sumdivisors(int num);

int main()
{
int startnum = 10,i;
int endnum = 2000;
struct amicable *ami;
ami = getAmicablePairs(startnum, endnum);
if(ami!=NULL)
{
printf("\n They are:");
printf("{");
for(i = 0; i<ami->size; i++)
{
printf("{%d, %d}",ami->amicablepair[i][0], ami->amicablepair[i][1]);
}
printf("}");
}
else
printf("Not Found:");
return 0;

}

struct amicable *getAmicablePairs(int startnum, int endnum)
{
int i,k=0,sums1=0,sums2=0;
struct amicable *ami;
ami->size=0;
if(startnum<0 || endnum<0 || endnum>15000 || startnum>endnum)
return NULL;
else
{
for(i=startnum;i<=endnum;i++)
{
sums1=sumdivisors(i);
sums2=sumdivisors(sums1);
if(sums2==i && i<sums1)
{
ami->amicablepair[k][0]=i;
ami->amicablepair[k][1]=sums1;
k++;
}
sums2=0;
sums1=0;
ami->size=k;
}
if(ami->size==0)
return NULL;
else
return(ami);
}
}
int sumdivisors(int num)
{
int i,sum=0;
for(i=1;i<num;i++)
{
if(num%i==0)
sum+=i;
}
return(sum);
}

I don't see a question. And don't double post.
struct amicable *ami;
ami->size=0;
Topic archived. No new replies allowed.