User Tools

Site Tools


c:stdlib.h:atof

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdlib.h:atof [2013/01/22 22:02]
c:stdlib.h:atof [2024/02/16 01:04] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +===== atof =====
 +<code c>
 +    #include <stdlib.h>
 +    double atof(const char *str);
 +</code>    
 +===== Description =====
 +<code c>
 +       The atof() function converts the initial portion of the string pointed to by
 +       nptr to double.  The behavior is the same as
 +
 +           strtod(nptr, (char **) NULL);
 +
 +       except that atof() does not detect errors.
 +</code>
 +
 +===== C Sourcecode Example =====    
 +<code c>
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +#include <stdlib.h>
 +
 +int main(void){
 +
 +    char string[]="1234";
 +    float i;
 +    
 +printf("string = %s \n", string );
 +printf("int = %f \n", atof(string) );
 +
 +i = atof(string);
 +i = i + i;
 +printf("i + i = %f\n", i);
 +
 +return 0;
 +}
 +
 +</code>
 +
 +==== Output ====
 +
 +    Output:
 +    user@host:~$ ./atof 
 +    string = 1234 
 +    int = 1234.000000 
 +    i + i = 2468.000000
 +
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War

Impressum Datenschutz