当前位置:网站首页>C语言EOF的理解
C语言EOF的理解
2022-07-28 05:23:00 【照洋】
理解
EOF是文件的结束符,是一个宏定义(C语言中所有的输入输出操作均是按读文件的思想来设计)
利用getchar与putchar函数能够能够把输入的字符经过检测,如不是文件结束指示符(当读文件操作时,遇到文件结束位置或读数据出错均会返回 EOF)后把该字符复制到输出。
#include<stdio.h>
#include<stdlib.h>
int
main()
{
int ch;
int line;
int at_begining;
line =0;
at_begining=1;
/*
*读取字符并逐个处理它们;
*/
while( (ch = getchar()) != EOF ){
/*
*如果我们位于一行的起始位置,打印行号;
*/
if (at_begining==1){
at_begining = 0;
line += 1;
printf("%d",line);
}
/*
*打印字符,并对行尾进行检测;
*/
putchar( ch );
if( ch == '\n')
at_begining = 1;
}
return EXIT_SUCCESS;
}该案例源代码实现:从标准输入读取几行输入。每行输入都要打印到输出上,前面都要加上行号。在编写程序时要试图让程序处理的输入行不受限制。
边栏推荐
- 基于差值扩展的可逆水印方法
- 深度学习(一):走进机器学习与深度学习理论部分
- 神经网络学习
- 一、AMD - OpenVINO环境配置
- 神经网络实现鸢尾花分类
- Reinforcement learning - dqn in value learning
- Reinforcement learning -- SARS in value learning
- Deep learning (self supervision: Moco V2) -- improved bases with momentum contractual learning
- Small program development solves the anxiety of retail industry
- 深度学习(增量学习)——(ICCV)Striking a Balance between Stability and Plasticity for Class-Incremental Learning
猜你喜欢

5、 Video processing and GStreamer

Byte Android post 4 rounds of interviews, received 50k*18 offers, and successfully broke the situation under the layoff

D2SC-GAN:基于双深浅通道生成对抗网络的课堂场景低分辨率人脸识别

Tensorflow2.1 basic concepts and common functions

pytorch深度学习单卡训练和多卡训练

循环神经网络

Neural network optimization

Overview of unconstrained low resolution face recognition II: heterogeneous low resolution face recognition methods

神经网络学习

UNL-类图
随机推荐
《On Low-Resolution Face Recognition in the Wild:Comparisons and New Techniques》低分辨率人脸识别论文解读
Various programming languages decimal | time | Base64 and other operations of the quick look-up table
Cluster operation management system, to answer questions about the process
self-attention学习笔记
Scenario solution of distributed cluster architecture: cluster clock synchronization
Nlp项目实战自定义模板框架
Tornado first met
Paper reading notes of field low resolution face recognition based on selective knowledge extraction
强化学习——价值学习中的DQN
Distributed cluster architecture scenario optimization solution: distributed scheduling problem
Sqlalchemy usage related
无约束低分辨率人脸识别综述二:异构低分辨率人脸识别方法
利用辅助未标记数据增强无约束人脸识别《Boosting Unconstrained Face Recognition with Auxiliary Unlabeled Data》
无约束低分辨率人脸识别综述三:同质低分辨率人脸识别方法
二、OpenVINO简述与构建流程
D2SC-GAN:基于双深浅通道生成对抗网络的课堂场景低分辨率人脸识别
自动定时备份远程mysql脚本
Improved knowledge distillation for training fast lr_fr for fast low resolution face recognition model training
transformer的理解
Tensorflow2.1 basic concepts and common functions