atold function

I want convert to string to long double but.i don't see _atold function.it's true but dont working.Does My header file don't have _atold?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <cstring>

using namespace std;
//////////////////////////////////
 long double mstold(char para[])
{
    long double money;
     int n=0;
     char karakter[100];
     int len = strlen(para);
     for(int i=0; i<len+1; i++)    
     {
             if(para[i] >= '0' && para[i] <= '9')
             {
                        karakter[n] = para[i];
                        n++;
             }
     }
     
                        
     money = _atold(karakter);
     
     return money;
}
     
     
int main(int argc, char *argv[])
{
    char choice;
    char string[100];
    long double para = 0;
 ////////////////////////////////////////
    do
    {
      cout << "Enter money: "; 
      cin >> string;
           
      para = mstold(string);
    
      cout << "Your cash is: " << para << endl;
      
      cout << "Do another ?(y/n)" ;
      cin >> choice;
      } while ( choice == 'y');
      
      

    
    system("PAUSE");
    return EXIT_SUCCESS;
}

problem is line 24.For example: "$999,4223,46343" convert to long double.but that doesn't works.But i change atold to atof it is working.but i want to convert long double
Last edited on
try strtold() (in stdlib.h or cstdlib)

thanks your answer.i have a question again.why my firs code doesn't working?
You have to null-terminate karakter array.
thank u
Topic archived. No new replies allowed.