I'm having trouble with my code and hope you could help. When I input an odd number I'm given a segmentation fault, and a bus error if it's even. I'm trying to add 00's to a data array to bring it from length Nprime to a new, larger length Ndprime that I input. I'm doing this in a function *fpad, where my paddata array contains Nprime complex numbers (i.e. 2*Nprime components), and needs to be brought up to size 2*Ndprime.
double *fpad(double *paddata, unsigned int Nprime, unsigned int Ndprime)
{
if (Nprime!=Ndprime)
{
paddata=(double*)realloc(paddata,(sizeof(double)*((2*Ndprime)-1)));
for(i>=((2*Nprime));i<(2*Ndprime);i++) paddata[i]=0;
if(paddata==NULL) /* Checks memory is reallocated */
{
printf("\nError reallocating memory.\n");
free(paddata);
exit(EXIT_FAILURE);
}
}
return(paddata);
}
ANy help would be appreciated, I can't see what I'm doing wrong.