Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

compiler error on atof(c.c_str)

Compiling a program containing this code:

using namespace std;
...
string c;
f = atof(c.c_str);

I get the following error in MSVC++

error C2664: 'atof' cannot convert parameter 1 from 'const char *(void) const' to 'const char *'

Anyone help?

0
zebada
Asked:
zebada
1 Solution
 
pesstCommented:
atof() takes a 'const char *' as the parameter, what is c_str set to?
maybe casting it to char* will work

f = atof((const char *)c.c_str);
0
 
pepenietoCommented:
You´re trying to convert a function (method) pointer to a char*. Try the next:

using namespace std;
....
string c;
f = atof(c.c_str());


0
 
zebadaAuthor Commented:
Thanks,

I remember falling for that one before.

That's what happens when I spend too much time coding in Delphi.

Paul
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now