[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 ...
随机推荐
- Windows Server2003本地用户的批量导入和导出(转)
AD域环境的用户导入和导出 Windows server 2003 批量导入用户---CSVDE 在新搭建的域环境中,有许多的域帐号需要导入,可以采用csvde命令来导入域用户:新建一个txt文本文件 ...
- 2018年Java实习春招总结
因为女票在北京,打算去北京实习,所以从去年12月开始复习Java,做项目,视频是看的黑马的视频,还可以吧,把Java基础和SSM框架看了下,做了个小项目,然后看牛客网的中级项目课,做了一个健身头条项目 ...
- 聪明的搜索算法’ A*算法
A*算法 是一种启发式的搜索算法. 了解BFS.DFS或者Dijkstra算法的人应该知道.这些算法都是一种向四周盲目式搜索的方法. 启发式搜索: 启发式搜索就是在状态空间中的搜索 ...
- 地址四级联动的vue组件
一.效果图如下: 二.思路 主要在vue中结合 mint-ui组件的Picker和Popup方法,负责对json地址进行展示: 三.代码地址 四.说明 address4.json最好是在点击父组件的地 ...
- Docker安装tomcat和部署项目
随着微服务的流行,Docker越来越流行,正如它的理念"Build, Ship, and Run Any App, Anywhere"一样,Docker提供的容器隔离技术使得开发人 ...
- 54. Spiral Matrix(中等)
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...
- centos 挂载ntfs格式的移动硬盘
经查找资料发现,linux也是可以支持ntfs格式分区的,只是需要安装ntfs-3g插件. CentOS挂载ntfs移动硬盘的具体步骤: 1 安装fuse. 下载fuse-2.9.3.tar.gz ...
- 原生Js写轮播图代码
html css js 在知道jQuery如何实现轮播效果的基础上,用js写代码 如图:标记这里的地方 理解一下 用到的知识: 1.HTML DOM 的appendChild() 和 removeCh ...
- Python3 CGI编程
什么是CGI CGI 目前由NCSA维护,NCSA定义CGI如下: CGI(Common Gateway Interface),通用网关接口,它是一段程序,运行在服务器上如:HTTP服务器,提供同客户 ...
- 亲密接触Redis-第三天(Redis的Load Balance)
前言 上两天讲述了Redis的基本搭建和基于HA的集群布署方式以及相关的策略和注意点.今天开始讲述Redis的Cluster功能,而这块目前来说网上资料不是太全,就算有1,2篇也只是单讲服务端的搭建也 ...