Hi all,
I am new to C programming and need some of your help. I am trying to convert a string(ex. 25,000) to an integer. I use the atoi function to do the conversion, however, it only reads the initial portion of the string by stopping at the first non-numerical character. In my case, it stores the value of "25" rather than "25000". How do I remove the comma and convert it to an integer? Please advise, thanks in advance.
Carol
int result;
extract_value(char* param_name)
{
char param[256], paramvalue[2048], *valueptr, valuestr[64];
int result;
sprintf(param, "{%s}", param_name);
strcpy(paramvalue, lr_eval_string(param));
if((valueptr = (char*)strstr(paramvalue, ">")) != NULL)
{
strcpy(valuestr, &valueptr[1]);
result = atoi(valuestr);
}
lr_output_message("Param: %s, Value: %d", param_name, result);
return result;
}