[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


atof

Convert a character string to a numeric value.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdlib.h>
double atof(const char *nptr);
Parameters:

Parameters for this facility are:

nptr  
const char *  
The character being converted  

Remarks:

The atof() function converts the character array pointed to by nptr to a floating point value of type double.

This function skips leading white space characters.

This function sets the global variable errno to ERANGE if the converted value cannot be expressed as a floating point value of type double.

Return:

atof() returns a floating point value of type double.

See Also:

"atoi"

"atol"

"errno"

"scanf"

Example of atof(), atoi(), atol() usage.:
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
	int i;
	long int j;
	float f;
	static char si[] = "-493", sli[] = "63870";
	static char sf[] = "1823.4034";

	f = atof(sf);
	i = atoi(si);
	j = atol(sli);

	printf("%f %d %ld\n", f, i, j);

	return 0;
}

Output:
1823.403400 -493 63870


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000