I am working with Borland C++ 5.02 compiling a C program to read an INI file with this function prototype:
extern const double readIniDouble( void *fp, const char *section, const char *name, const double defValue );
I can read the value with no problem with this code:
double test;
test = readIniDouble( iniFile, "ASection", "AName", 2 );
cprintf( "%e", test ); // Correctly writes the default value of '2'
The problem is that I need to get the value into a struct:
static struct settings tmp_set;
tmp_set.aSetting = readIniDouble( iniFile, "ASection", "AName", 2 );
cprintf( "%e", &tmp_set.aSetting ); // does not work
This compiles but prints an unexpected large number. If I use an ampersand or asterisk in front of tmp_set on the left side of the assignment (&tmp_set.aSetting = ... ) I get a compiler error 'Illegal use of floating point'.
What is the correct syntax to assign the return value of the iniReadDouble() function directly to the struct member?
2007-03-15
15:52:37
·
2 answers
·
asked by
codesuidae
1