getchar_unlocked in windows undeclared

后端 未结 3 1027
广开言路
广开言路 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:52

    getchar_unlocked() is mainly used for competitive programming, however, if you want to use this elsewhere, just make sure, only 1 thread is using it at a time. Same applies to putchar_unlocked() function too. It is a POSIX equivalent so Windows compiler doesn't support it. However, you can use either of two-

    1) Normal speed

    int getchar_unlocked() { return getchar(); }
    void putchar_unlocked(char _c) {return putchar(_c); }
    

    2) Fast speed

    int getchar_unlocked() { return _getchar_nolock(); }
    void putchar_unlocked(char _c) { return _putchar_nolock(_c); }
    

提交回复
热议问题