ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

d

2019-10-07 22:50:27  阅读:186  来源: 互联网

标签: use EOF int character printf getchar


Xx_Introduction

  • Character input and output is by more line character conpose of the text flow 
  • Define name common use capital  letter,easy read.
  • The Standard C Library ----->provide I/O model ------>use character flow way.

Ax_Application

  • file copy,charater count,line count,word count

Bx_Method

  • I/O model common use getchar and putchar,interactive use of putchar and printf.
    1 getchar()     //read next character
    2 putcahr()     //print next character
    3 printf()        //print next(bunch) character
  • File Copy
    • file copy version 1
       1 #include<stdio.h>
       2 
       3 int main()
       4 {
       5     int c;
       6     
       7     c = getchar();
       8     while(c != EOF){
       9         putchar(c);
      10         c = getchar();
      11     }
      12 }
    • file copy version 2
       1 #include<stdio.h>
       2 
       3 int main()
       4 {
       5     int c;
       6     
       7     while((c = getchar())!= EOF){
       8         putchar(c);
       9     }
      10 }

      != : unequal to. priority overtop assignment(=)             EOF:end of file

    • Conclusion:computer use bit storage of character and any data type.
    • Assignment can portion of expression.
    • Complex statement simple easy read,but so hard understand.
    • Due to unequal to relational operator(!=) priority not overtop assignment(=),so c expression use bracket.
       1 #include <stdio.h>
       2 
       3 int main()
       4 {
       5     int c;
       6 
       7     while (c = getchar() != EOF){
       8         printf("%d\n",c);
       9     }
      10     printf("%d - at EOF\n",c);
      11     return 0;
      12 }

      if not use bracket,will priority operation EOF,value by 1,if input end or else print "c - at EOF".

    • Print EOF value programming
      1 #include <stdio.h>
      2 
      3 int main()
      4 {
      5     printf("EOF is %d\n",EOF);
      6     return 0;
      7 }

      character constant EOF is in <stdio.h> file definition,value by -1 

    • In other system can by definition other value. 
  • Charater Count

标签:,use,EOF,int,character,printf,getchar
来源: https://www.cnblogs.com/enomothem/p/11632748.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有