[C]simple code of count input lines,words,chars
This is a simple C program which can count input lines, words and chars. But the number of words are not very strict. It likes simple
wccommand.
#include<stdio.h>
/* 简单的统计行数,单词数目,字符个数等
my_wc.c by orangleliu
*/
int main()
{
int c, nl, nw, nc, flag;
nl = nw = nc =0;
while((c = getchar()) != EOF)
{
++nc;
if( c == '\n' )
++nl;
if( c == ' '|| c == '\t' || c == '\n')
flag = 1;
else if ( flag == 1){
++nw;
flag = 0;
}
}
printf("line %d words %d chars %d \n", nl, nw, nc);
}
res
lzz-rmbp|file # cat my_wc.c|./a.out
line 25 words 68 chars 447
[C]simple code of count input lines,words,chars的更多相关文章
- Entity Framework Code-First(4):Simple Code First Example
Simple Code First Example: Let's assume that we want to create a simple application for XYZ School. ...
- 1.2 Simple Code!(翻译)
Simple Code! 简洁编码 Playing football is very simple, but playing simple football is the hardest thing ...
- Python: simple code
# !/usr/bin/env python3.6 # -*- coding: utf-8 -*- # visual studio 2017 # 2019 10 12 Geovin Du print ...
- C lang:character input and output (I/O)
Xx_Introduction Character input and output is by more line character conpose of the text flow Defin ...
- PHP命令行模式基本介绍
首先要保证php在cli模式下可用,php –v会返回PHP的版本号. [gaojian3@log001 ~]$ php -v PHP (cli) (built: Aug ::) Copyrigh ...
- php命令行用法简介
Php是一个非常流行的web服务端脚本语言.其实,php不仅仅可以在web服务器中充当重要角色.在命令行一样可以执行. 本文中,笔者为各位介绍下php在命令行中的使用方法. 1. 查看php的版本. ...
- jQuery选择器中,通配符[id^='code']input[id$='code'][id*='code']
1.选择器 (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']&qu ...
- Code Complete阅读笔记(二)
2015-03-06 328 Unusual Data Types ——You can carry this technique to extremes,putting all the ...
- 7. Input and Output
7. Input and Output There are several ways to present the output of a program; data can be printed i ...
随机推荐
- cmake 没有那个目录
问题:bash: /usr/bin/cmake: 没有那个文件或目录 因为直接使用cmake系统回到默认的/usr/bin中去寻找,但是src中安装的cmake是在/usr/local/bin中,所以 ...
- 笔记12 注入AspectJ切面
虽然Spring AOP能够满足许多应用的切面需求,但是与AspectJ相比, Spring AOP 是一个功能比较弱的AOP解决方案.AspectJ提供了Spring AOP所不能支持的许多类型的切 ...
- .net 导入excel数据
using System; using System.Data; using System.Data.OleDb; using System.Data.SqlClient; using System. ...
- pytorch_SRU(Simple Recurrent Unit)
导读 本文讨论了最新爆款论文(Training RNNs as Fast as CNNs)提出的LSTM变种SRU(Simple Recurrent Unit),以及基于pytorch实现了SRU,并 ...
- Linux常用命令大全(归类)
最近都在和Linux打交道,这方面基础比较薄弱的我只好买了本鸟哥的书看看,感觉还不错.我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因, ...
- java怎样获取CPU占用率和硬盘占用率
通过jmx可以监控vm内存使用,系统内存使用等,以下是网上某博客代码,特点是通过window和linux命令获得CPU使用率. 利用java程序实现获取计算机cpu利用率和内存使用信息. packag ...
- Angular 路由配置
路由,简单的来说就是让组件之间进行跳转和参数的传递. 1.先在app目录下创建一个名为app.route.ts的路由组件 2.打开app.route.ts 在里面创建路由组件的代码(可通过编辑器快捷生 ...
- 基于PHP的对接免费电子面单接口平台的案例-快宝开放平台
一.电子面单对接平台 电子面单对接平台分为两类: 1 .各大快递公司自有的电子面单接口开放平台:对接起来麻烦,需要每个快递公司分别调试接口,费时费力. 2 .第三方快递开放平台:如快宝开放平台(htt ...
- 【python标准库模块三】Os模块和Sys模块学习
Os模块 导入os模块 import os 获取当前工作目录 os.getcwd() 切换目录,跟linux中的cd一样 os.chdir("文件夹名") 递归生成文件夹 os.m ...
- MongoDB Java
MongoDB Java 环境配置 在Java程序中如果要使用MongoDB,你需要确保已经安装了Java环境及MongoDB JDBC 驱动. 你可以参考本站的Java教程来安装Java程序.现在让 ...