小剑剑 发表于 2016-3-15 20:57:57

c的putchar

图中箭头怎么来的?
#include "stdio.h"
main(){
    char c=getchar();
    while (c!=EOF){
      putchar(c);
      c=getchar();
    }
    return 0;
}

输入的字符最后一个虽然数回车,但遇到EOF不是就结束了吗,怎么会多个箭头

n0noper 发表于 2016-3-16 08:33:04

MSDN说:The return value is EOF for an error or if the end-of-file character or the end-of-string character is encounteredin the first attempt to read a character.
// Ctrl+Z必须是输入行第一个字符

而撸主输入的Ctrl+z对应输入的ASCII码对应的就是右箭头 (Ctrl+Y就是↓,详情请查看ASCII码表)

小剑剑 发表于 2016-3-16 08:35:48

n0noper 发表于 2016-3-16 08:33
MSDN说:The return value is EOF for an error or if the end-of-file character or the end-of-string ch ...

谢谢鱼油
页: [1]
查看完整版本: c的putchar