jkepler
June 5th, 2009, 09:50 AM
Hi,
In another Thread , I was kindly given a way to put a string in the environment environment. Now, I'm trying to place a double. I've tryed the following code:
void Setenv(double vx)
{
char* key = "KP_VAL=";
char num[100];
sprintf(num,"%lf",vx);
char* exp = (char*) malloc(strlen(num) + strlen(key) + 1);
strcpy(exp , key );
strcat(exp ,num);
putenv(exp);
free(exp);
free(key);
free(num);
}
but it gives me several errors.
Can someone help me?
Kind regards,
JKepler
In another Thread , I was kindly given a way to put a string in the environment environment. Now, I'm trying to place a double. I've tryed the following code:
void Setenv(double vx)
{
char* key = "KP_VAL=";
char num[100];
sprintf(num,"%lf",vx);
char* exp = (char*) malloc(strlen(num) + strlen(key) + 1);
strcpy(exp , key );
strcat(exp ,num);
putenv(exp);
free(exp);
free(key);
free(num);
}
but it gives me several errors.
Can someone help me?
Kind regards,
JKepler