What is the ascii value of EOF in c.?

前端 未结 7 817
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 13:51

Any one knows what is the ASCII value of i.

I try printf(\"%d\",EOF);

but its print -1

and also try printf(\"%c\",EOF

7条回答
  •  眼角桃花
    2020-12-01 14:34

    EOF is not an ASCII character. Its size is not 1 byte as against size of a character and this can be checked by

    int main() {
        printf("%lu", sizeof(EOF));
        return 0;
    }
    

    However, it is always defined to be -1. Try

    int main() {
        printf("%d",EOF);  
        return 0;
    }
    

    The key combination for EOF is Crtl+D. The character equivalent of EOF is machine dependent. That can be checked by following:

    int main() {
        printf("%c", EOF)
        return 0;
    }
    

提交回复
热议问题