P
parjit
Hi,
when a run the following program the first and the second fprintf work
well but the third causes a bus error. (on a SUN Sparc Station 2, on a
VAX station there is no bus error).
#include<stdio.h>
#include<string.h>
main()
{
char longstr[1000];
char str[1000];
double d = 3.1415926535897932384626433832795028841971;
double *pd=&d;
strncpy(longstr,(char *)pd,sizeof(double));
strncpy(&longstr[10],(char *)pd,sizeof(double));
fprintf(stdout," %15.15f\n",*(double *)&(longstr[0]));
strcpy(str,&(longstr[10]));
fprintf(stdout," %15.15f\n",*(double *)&(str[0]));
fprintf(stdout," %15.15f\n",*(double *)&(longstr[10]));
return(0);
}
Does anybody know why? Any ideas are wellcome. Thnx.
when a run the following program the first and the second fprintf work
well but the third causes a bus error. (on a SUN Sparc Station 2, on a
VAX station there is no bus error).
#include<stdio.h>
#include<string.h>
main()
{
char longstr[1000];
char str[1000];
double d = 3.1415926535897932384626433832795028841971;
double *pd=&d;
strncpy(longstr,(char *)pd,sizeof(double));
strncpy(&longstr[10],(char *)pd,sizeof(double));
fprintf(stdout," %15.15f\n",*(double *)&(longstr[0]));
strcpy(str,&(longstr[10]));
fprintf(stdout," %15.15f\n",*(double *)&(str[0]));
fprintf(stdout," %15.15f\n",*(double *)&(longstr[10]));
return(0);
}
Does anybody know why? Any ideas are wellcome. Thnx.