Domanda

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;
}
È stato utile?

Soluzione 2

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).

Altri suggerimenti

The atoll function was introduced to the standard C language in C99.

Unfortunately Microsoft ignored C99 for a long time and didn't implement any of its features in the Visual Studio C compiler, up to and including VS 2012.

This changed with VS 2013 which added considerable, but not complete, C99 support.

The easiest option is probably to use _strtoi64 which should be available, but be aware that this is a Microsoft specific function so probably won't work if you try to compile your code elsewhere.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top