1 //看EOF的值 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 int main(void) 6 { 7 printf("EOF的值用數字表示爲:%d\n", EOF); 8 system("pause"); 9 return 0; 10 }
1 //驗證getchar()!= EOF的值 2 3 #include <stdio.h> 4 5 int main(void) 6 { 7 printf("隨便按個鍵,Ctrl+D或Ctrl+Z表明EOF\n"); 8 printf("表達式 getchar() != EOF 的值爲 %d\n", getchar()!= EOF); 9 system("pause"); 10 return 0; 11 }
結果:Ctrl+D ---> 1 ; Ctrl + Z ---> 0
#include <stdio.h> int main(void) { //注:建議使用標準的轉義字符(\n,\t,\b,\",\\之類),若是使用非標準的轉義字符,結果將變得不可預期(好比下面的\a,\f,\r,\v 之類) printf("\\Audible or visual alert. \a\n"); printf("Form feed. \f\n"); printf("This escape, \r, moves the active position to the initial position of the current line.\n"); printf("Vertical tab \v is tricky, as its behaviour is unspecified under certain conditions.\n"); return 0; }
#include <stdio.h> int main(void) { printf("EOF的值用數字表示爲:%d\n", EOF);return 0; } 結果:-1