码迷,mamicode.com
首页 > 其他好文 > 详细

C基础巩固

时间:2015-05-10 22:10:48      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

 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

 

技术分享

 

C基础巩固

标签:

原文地址:http://www.cnblogs.com/tangtang-123/p/4492910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!