Does anyone know , how to do the conversion from Ascii to long double?
Please provide one example.

Many Thanks.

Recommended Answers

All 4 Replies

I'm unsure what you mean... do you want something like atof()? It's a C function that does the conversion. If you want C++, you'll have to use std.atof() or stringstreams.

Here's a code example:

char c_number[] = "45.33";
double d_number = atof(c_number);

And with stringstreams:

std::stringstream s_number("45.33");
double d_number;
s_number >> d_number;

Hope this helps

thanks for your answer.
i wanted to know, do we have any conversion function in C to convert ascii to long double as the same way we do for atof()?

thanks for your answer.
i wanted to know, do we have any conversion function in C to convert ascii to long double as the same way we do for atof()?

You've already been shown how to do it in both C and C++ - whats wrong with those methods?

thanks for your answer.
i wanted to know, do we have any conversion function in C to convert ascii to long double as the same way we do for atof()?

Use Joey's advice and just put the word 'long' in front of 'double'

Niek

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.