Solved

compiler error on atof(c.c_str)

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

617 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