-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtoi.cpp
52 lines (40 loc) · 1.01 KB
/
Atoi.cpp
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
/**
* \file Atoi.cpp
* \brief Convert Non-number values to int, double
*/
//---------------------------------------------------------------------------
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//---------------------------------------------------------------------------
int main(int, char **)
{
std::string s;
int a = std::atoi( s.c_str() );
std::cout << STD_TRACE_VAR(a) << std::endl;
int b = std::atoi("");
std::cout << STD_TRACE_VAR(b) << std::endl;
int c = std::atoi("NULL");
std::cout << STD_TRACE_VAR(c) << std::endl;
#if 0
int d = std::atoi(nullptr);
std::cout << d << std::endl;
#endif
/**
* Need for fix:
*
* - Remove - "$"
* - Replace - "," -> "."
*/
double e = std::strtod("$27,41", nullptr);
std::cout << STD_TRACE_VAR(e) << std::endl;
return EXIT_SUCCESS;
}
//---------------------------------------------------------------------------
#if OUTPUT
a: 0
b: 0
c: 0
d: Segmentation fault
e: 0
#endif