C lang:character input and output

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

原文地址:https://www.cnblogs.com/enomothem/p/11632748.html

时间: 2024-08-01 03:45:34

C lang:character input and output的相关文章

spring cloud Stream input和output重名报错

目前项目是用的springboot 2.0.5.RELEASE,版本号为:Finchley.SR2客户端测试代码如下: import org.springframework.cloud.stream.annotation.Input; import org.springframework.cloud.stream.annotation.Output; import org.springframework.messaging.MessageChannel; import org.springfra

[20160704]Addition program that use JOptionPane for input and output

1 //Addition program that use JOptionPane for input and output. 2 3 import javax.swing.JOptionPane; 4 5 public class Addition{ 6 public static void main(String[] args) { 7 String firstNumber=JOptionPane.showInputDialog("Enter first integer!"); 8

File Input and Output

Use of File Stream Assume ifle and ofile is the string object storing the names of input and output files' namess. string ifile = "inputFile.txt"; string ofile = "outputFile.txt"; Then the use of file stream is like this: // construct

标准库 - 输入输出处理(input and output facilities) lua

标准库 - 输入输出处理(input and output facilities)责任编辑:cynthia作者:来自ITPUB论坛 2008-02-18 文本Tag: Lua [IT168 技术文档]I/O库提供两种不同的方式进行文件处理1.io表调用方式:使用io表,io.open将返回指定文件的描述,并且所有的操作将围绕这个文件描述 io表同样提供三种预定义的文件描述io.stdin,io.stdout,io.stderr2.文件句柄直接调用方式,即使用file:XXX()函数方式进行操作,

转载:Pixhawk源码笔记四:学习RC Input and Output

转自:新浪@WalkAnt 第五部分 学习RC Input and Output 参考:http://dev.ardupilot.com/wiki/learning-ardupilot-rc-input-output/ RC Input,也就是遥控输入,用于控制飞行方向.改变飞行模式.控制摄像头等外围装置.ArduPilot支持集中不同RC input(取决于具体的硬件飞控板): 1. PPMSum – on PX4, Pixhawk, Linux and APM2 2. SBUS – on P

Python Tutorial 学习(七)--Input and Output

7. Input and Output Python里面有多种方式展示程序的输出.或是用便于人阅读的方式打印出来,或是存储到文件中以便将来使用.... 本章将对这些方法予以讨论. 两种将其他类型的值转换为字符型值的方法:repr()和str(),二者的区别在于,一个是给机器读的,一个是给人读的,str()返回的是更适合人阅读的样式 一些栗子: >>> s = 'Hello, world.' >>> str(s) 'Hello, world.' >>>

Input and Output Method

IO stands for input and output in programming. IO is important in programming, especially in Olympic Informatic, due to the policy of it. Therefore, as a contestant in Olympic Informatic, it's neccesary for me to sumarize the method of IO, in order t

java.lang.character cannot be cast to java.lang.String

今天在因为修改了存储过程的参数,要增加传入的参数,数据为Mysql.在写的过程中,把这默认传值简单的写成了死值.但是运行后发现报错了. java.lang.character cannot be cast to java.lang.String 这个错误.然后查代码,上网找答案.最后终于解决了. 是因为我在传值的时候写的是. '0' 这样传入的值就带着单引号一起传了. 最后修改成"0". 问题解决. 这个也不算什么大问题,只是平时在写代码的时候不太注意. 希望自己以后改掉这个毛病. 与

angular 的 @Input、@Output 的一个用法

angular 使用 @input.@Output 来进行父子组件之间数据的传递. 如下: 父元素: <child-root parent_value="this is parent value" (child_emit)="test()"></child-root> 父元素标签中有一个属性是,parent_value,在子元素中可以使用该值: <p [title]="parent_value" >this p