Dear All,
I am puzzled by how to use strtod(). I have pasted its man page below. I
don't understand what char **endptr is and why it is needed there.
Thank you very much.
STRTOD(3) Library functions
STRTOD(3)
NAME
strtod, strtof, strtold - convert ASCII string to floating point
number
SYNOPSIS
#include <stdlib.h>
double strtod(const char *nptr, char **endptr);
float strtof(const char *nptr, char **endptr);
long double strtold(const char *nptr, char **endptr);
DESCRIPTION
The strtod, strtof, and strtold functions convert the initial
portion of the string pointed to by nptr to double,
float, and long double representation, respectively. 3 1800
On 2005-12-16, Xiaoshen Li <xl**@gmu.edu> wrote: Dear All,
I am puzzled by how to use strtod(). I have pasted its man page below. I don't understand what char **endptr is and why it is needed there.
Thank you very much. STRTOD(3) Library functions STRTOD(3)
NAME strtod, strtof, strtold - convert ASCII string to floating point number
SYNOPSIS #include <stdlib.h>
double strtod(const char *nptr, char **endptr); float strtof(const char *nptr, char **endptr); long double strtold(const char *nptr, char **endptr);
DESCRIPTION The strtod, strtof, and strtold functions convert the initial portion of the string pointed to by nptr to double, float, and long double representation, respectively.
If that's the whole manpage, then you have a crappy manpage.
An exerpt from my manpage: RETURN VALUES The strtod(), strtof(), and strtold() functions return the converted value, if any.
If endptr is not NULL, a pointer to the character after the last character used in the conversion is stored in the location referenced by endptr.
If no conversion is performed, zero is returned and the value of nptr is stored in the location referenced by endptr.
I found the solution. Sorry for bothering.
endptr will point to the string(==pointer to a char array)
Xiaoshen Li wrote: Dear All,
I am puzzled by how to use strtod(). I have pasted its man page below. I don't understand what char **endptr is and why it is needed there.
Thank you very much. STRTOD(3) Library functions STRTOD(3)
NAME strtod, strtof, strtold - convert ASCII string to floating point number
SYNOPSIS #include <stdlib.h>
double strtod(const char *nptr, char **endptr); float strtof(const char *nptr, char **endptr); long double strtold(const char *nptr, char **endptr);
DESCRIPTION The strtod, strtof, and strtold functions convert the initial portion of the string pointed to by nptr to double, float, and long double representation, respectively.
Please do not top-post.
Xiaoshen Li wrote:
[Question: How to use strtod(), especially the char** parameter] I found the solution. Sorry for bothering.
endptr will point to the string(==pointer to a char array)
<snip>
Here is an example how to use strtol(); you should be able
to adapt it to strtod(): http://home.att.net/~jackklein/c/code/strtol.html
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brian Sabbey |
last post by:
Here is a first draft of a PEP for thunks. Please let me know what you
think. If there is a positive response, I will create a real PEP.
I made a patch that implements thunks as described here....
|
by: da Vinci |
last post by:
OK, this has got to be a simple one and yet I cannot find the answer
in my textbook.
How can I get a simple pause after an output line, that simply waits
for any key to be pressed to move on?
...
|
by: JKop |
last post by:
Take the following simple function:
unsigned long Plus5Percent(unsigned long input)
{
return ( input + input / 20 );
}
Do yous ever consider the possibly more efficent:
|
by: Alan |
last post by:
hi all,
I want to define a constant length string, say 4
then in a function at some time, I want to set the string to a constant
value, say a
below is my code but it fails
what is the correct...
|
by: Giancarlo Berenz |
last post by:
Hi:
Recently i write this code:
class Simple
{
private:
int value;
public:
int GiveMeARandom(void);
|
by: AndersWang |
last post by:
Hi,
dose anybody here explain to me why memset would be faster than a
simple loop. I doubt about it!
In an int array scenario:
int array;
for(int i=0;i<10;i++) //ten loops
|
by: =?ISO-8859-1?Q?Tor_Erik_S=F8nvisen?= |
last post by:
Hi,
A while ago I asked a question on the list about a simple eval
function, capable of eval'ing simple python constructs (tuples, dicts,
lists, strings, numbers etc) in a secure manner:...
|
by: copx |
last post by:
Can anyone point me to a simple, fast RRNG function to generate random ints
within a specified range? It is important that each value within the range
has the same probability (uniform...
|
by: jerry |
last post by:
i have written a simple phonebook program,i'll show you some of the
codes,the program's head file is member.h . i suppose the head file
works well.so i don't post it. here's the clips of main...
|
by: Chris M. Thomasson |
last post by:
I use the following technique in all of my C++ projects; here is the example
code with error checking omitted for brevity:
_________________________________________________________________
/*...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |