getchar_unlocked in windows undeclared

后端 未结 3 1002
广开言路
广开言路 2021-01-03 06:11

Here is my code:

#include 

void scan(int* i)
{
    int t=0;
    char c;
    bool negative=false;
    c=getchar_unlocked();
    while(c<\'0         


        
3条回答
  •  时光说笑
    2021-01-03 06:41

    getchar_unlocked is not a C or C++ standard function and therefore it's no surprise that it doesn't work on Windows. It is a POSIX standard I think, but Windows compilers don't support all POSIX functions.

    If you replaced getchar_unlocked with getchar, it would kind of work, although the algorithm doesn't seem quite right.

    You could do this with conditional compilation, like this for instance

    #ifdef _WINDOWS
    // no getchar_unlocked on Windows so just call getchar
    inline int getchar_unlocked() { return getchar(); }
    #endif
    

提交回复
热议问题