Solved

compiler error on atof(c.c_str)

Posted on 2000-04-06
3
379 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
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 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now