Hi all,
using the following code;
#include <stdio.h>
#include <stdlib.h>
int main () {
char *val = "1.234";
double pnum;
pnum = strtod(val, NULL);
printf("%f\n", pnum);
return(0);
}
works just fine and dandy however writing the code like this;
#include <stdio.h>
#include <stdlib.h>
int main () {
char *val = "1.234";
double *pnum;
*pnum = strtod(val, NULL);
printf("%f\n", *pnum);
return(0);
}
results in segmentation faults, exceptions and general mayhem.
Any ideas why?
Can you declare a pointer to a double?
greadey.
using the following code;
#include <stdio.h>
#include <stdlib.h>
int main () {
char *val = "1.234";
double pnum;
pnum = strtod(val, NULL);
printf("%f\n", pnum);
return(0);
}
works just fine and dandy however writing the code like this;
#include <stdio.h>
#include <stdlib.h>
int main () {
char *val = "1.234";
double *pnum;
*pnum = strtod(val, NULL);
printf("%f\n", *pnum);
return(0);
}
results in segmentation faults, exceptions and general mayhem.
Any ideas why?
Can you declare a pointer to a double?
greadey.