当前位置:网站首页>c语言:11、管道
c语言:11、管道
2022-07-27 16:47:00 【兔头哥哥】
c语言:11、管道
1、linux管道简介
查看/etc/下面有没有包含ab字符的文件ls /etc/ | grep ab
上方命令本质是将ls命令的输出流作为grep命令的输入流
2、c语言使用管道例子
/avg.c
avg.c主要计算两个数字的平均值
#include <stdio.h>
int main()
{
int sum,num;
scanf("%d,%d", &sum,&num);
float result = sum/num;
printf("result=%f\n", result);
return 0;
}

/input.c
input.c主要统计输入的所有数字的总和以及数量
#include <stdio.h>
int main()
{
int flag=1;
int i;
int count=0;
int s=0;
while(flag){
scanf("%d", &i);
if(0==i) break;
count++;
s+=i;
}
printf("%d,%d\n", s, count);
return 0;
}

avg.c和input.c使用管道串联起来,计算3000+2000的平均值
边栏推荐
- MySQL learning notes (2) -- stored procedures and stored functions
- Cumulative output data of kettle Excel
- 阿里云对象存储OSS的开通和使用
- Usage of ref keyword
- Using MATLAB to generate graphics for journals and conferences - plot
- Kettle learning - the repository configuration in version 8.2 is grayed out, and there is no connect button
- win10小技巧(1)——转移桌面位置
- [Luogu p4183] cow at large P (graph theory) (tree array)
- Cyclic multi-Variate Function for Self-Supervised Image Denoising by Disentangling Noise from Image
- Greedy method, matroid and submodular function (refer)
猜你喜欢

内存管理A4

Analysis of Eureka server

ES6学习笔记(1)——快速入门

Error analysis of building Alibaba cloud +typera+picgo map bed

MySQL学习笔记(2)——存储过程与存储函数

新系统安装MySQL+SQLyog

Basic network faults and troubleshooting

An article allows you to master threads and thread pools, and also solves thread safety problems. Are you sure you want to take a look?

ipfs通过接口获得公钥、私钥,并加密存储。第一弹

kettle8.2 安装及常见问题
随机推荐
Definition of graph traversal and depth first search and breadth first search (2)
kettle 合并记录 数据减少
Technology Summit 58 Liu Yuan in the same city was invited to attend qecon 2022 global software quality & effectiveness conference
sql 字段类型转换
汉字查拼音微信小程序项目源码
[Luogu p4183] cow at large P (graph theory) (tree array)
Unity learning notes (rigid body physics collider trigger)
Matrix of shell programming -- it's cute and cool
每日一题(02):倒置字符串
kettle学习——8.2版本的资源库配置变为灰色,且没有了Connect按钮
JMeter interface automation - how to solve the content type conflict of request headers
Micaz+tinyos learning notes (1)
asp. Net experience
Useful resources for ns2
IDEA连接数据库时区问题,报红Server returns invalid timezone. Need to set ‘serverTimezone‘ property.
Unity learning notes - six common functions of object movement
IDEA成功连接Database但不显示表怎么办
C语言案例:密码设置及登录> 明解getchar与scanf
Word 2007+ tips
Study notes of Microcomputer Principles - general integer instructions and Applications