convertion Fialed

I want to convert char[21] (string) to long long, so I used atoll () and strtoll, but those function not convert the value it give some wrong value, pls help me to solve the issue, i give the input values and sample code.

long long l_llTimeStamp = 0
char lStrTimeStamp[21];

strcpy (lStrTimeStamp, "20130628173208612799");

l_llTimeStamp = strtoll (lStrTimeStamp, NULL, 21);
l_llTimeStamp = atoll (lStrTimeStamp);

After Conversion I got this value :----> 9223372036854775807
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>

int main()
{
    std::string s( "20130628173208612799" );

    try
    {
        long long result = std::stoll(s) ;
        std::cout << result << '\n' ;
    }

    catch(std::exception& ex)
    {
        std::cout << "Unable to convert \"" << s << "\"\n\t" ;
        std::cout << ex.what() << '\n' ;
    }
}
Unable to convert "20130628173208612799"
        stoll argument out of range


Topic archived. No new replies allowed.