Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

compiler error on atof(c.c_str)

Posted on 2000-04-06
3
Medium Priority
?
404 Views
Last Modified: 2010-04-10
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
Comment
Question by:zebada
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:pesst
ID: 2688943
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
 
LVL 1

Accepted Solution

by:
pepenieto earned 200 total points
ID: 2689056
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
 
LVL 6

Author Comment

by:zebada
ID: 2689082
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question