fread了解一下

神奇读入挂_

记得加头文件#include

    const int BufferSize=100*1000;
    char buffer[BufferSize],*head,*tail;
    bool not_EOF=true;
    inline char Getchar(){
        if(not_EOF and head==tail){
            int len=fread(buffer,1,BufferSize,stdin);
            not_EOF=len!=0;
            head=buffer,tail=head+len;
        }
        return not_EOF?*head++:-1;
    }
    inline int rd(){
        int x=0,s=1;
        char c=Getchar();
        for(;!isdigit(c) and not_EOF;c=Getchar()) if(c=='-') s=-1;
        for(; isdigit(c) and not_EOF;c=Getchar()) x=(x<<1)+(x<<3)+(c^48);
        return s*x;
    }
    inline void scan(char *str){
        char c=Getchar();
        for(; isspace(c) and not_EOF;c=Getchar());
        for(;!isspace(c) and not_EOF;c=Getchar()) *(str++)=c;
        *str=0;
}
原文地址:https://www.cnblogs.com/ezoihy/p/9368335.html