language: C++ 4.7.2 (gcc-4.7.2)
date: 899 days 3 hours ago
link:
visibility: private
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
#include <climits>
#include <string>
#include <stdio.h>
#include <stdlib.h>
 
std::string itostr(int val)
{
    std::string retval(14, '\0');
    ltoa(val, &retval[0], 10);
    return retval;
}
 
std::string itostr(unsigned val)
{
    std::string retval(14, '\0');
    ultoa(val, &retval[0], 10);
    return retval;
}
 
int main(void)
{
    int i = 0;
    i += itostr(INT_MIN).size();
    i += itostr(INT_MAX).size();
 
    i += itostr(unsigned(INT_MAX) + 1U).size();
    i += itostr(unsigned(~0)).size(); 
 
        char c = CHAR_MIN;
        do {
                i += itostr(c).size();
                i += itostr((11111111 * c)).size();
 
                if (c >= CHAR_MAX) break;
 
                c++;
        } while (1);
 
    while (i < 100000000)
        i += itostr(i).size();
 
    printf("%d\n", i);
 
    return i;
}
prog.cpp: In function ‘std::string itostr(int)’:
prog.cpp:9: error: ‘ltoa’ was not declared in this scope
prog.cpp: In function ‘std::string itostr(unsigned int)’:
prog.cpp:16: error: ‘ultoa’ was not declared in this scope