Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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