Search code examples
cstringvisual-studio-2012type-conversionlong-long

Converting string to long long


I used the solution given in

Troubling converting string to long long in C

to convert a string to long long in C. I am using Microsoft Visual Studio 2012.

On compiling I am getting the error

LNK2019: unreslved external symbol _+atoll referenced in function _main.

#include <stdio.h>
#include <stdlib.h>  


int main(void) {
    char s[30] = { "115" };
    long long t = atoll(s);

    printf("Value is: %lld\n", t);

    return 0;
}

Solution

  • atoll is deprecated and seems not to be included in the newest VS release. Use strtoll

    long long t = strtoll(s, NULL, 10);
    

    If that is unavailable either then see if _strtoi64 is (has the same prototype).