S
shadab
I am having big problem retrieving data assgined to dynamic 2-d array .
i am calculating and saving data in to dynamic 2-d array.
but when i retrieve them, it doesnt give correct values.
you can run following code in C compiler and see the difference
follwoing is my code, please have a look and please reply to
(e-mail address removed)
TIA
#include <stdio.h>
#include <memory.h>
main()
{
double *a;
int i, j, lx=5;
a= (double *)malloc(lx*2);
for (i=0; i<lx; i++)
{
for(j=0;j<lx; j++)
{
*(a+i+j)= i+j*0.3;
printf("a[%d][%d]=%f\n",i,j,*(a+i+j));
}
}
printf("copy data \n\n\n");
for (i=0; i<lx; i++)
{
for(j=0;j<lx; j++)
{
printf("a[%d][%d]=%f\n",i,j,*(a+i+j));
}
}
free(a);
}
i am calculating and saving data in to dynamic 2-d array.
but when i retrieve them, it doesnt give correct values.
you can run following code in C compiler and see the difference
follwoing is my code, please have a look and please reply to
(e-mail address removed)
TIA
#include <stdio.h>
#include <memory.h>
main()
{
double *a;
int i, j, lx=5;
a= (double *)malloc(lx*2);
for (i=0; i<lx; i++)
{
for(j=0;j<lx; j++)
{
*(a+i+j)= i+j*0.3;
printf("a[%d][%d]=%f\n",i,j,*(a+i+j));
}
}
printf("copy data \n\n\n");
for (i=0; i<lx; i++)
{
for(j=0;j<lx; j++)
{
printf("a[%d][%d]=%f\n",i,j,*(a+i+j));
}
}
free(a);
}