Giter Site home page Giter Site logo

wc's Introduction

Word Count Utility

This project is my own reimplementation of the Unix command-line utility wc. It provides word count statistics for a given file. The program supports counting bytes, lines, words, and characters. It can also handle multi-byte characters based on the locale of the computer.

Features

Usage

$ ./wc [OPTION] [FILE]

Options:

-c: Outputs the number of bytes.
-l: Outputs the number of lines.
-w: Outputs the number of words.
-m: Outputs the number of characters (handles multi-byte characters based on the locale).

Example:

This command will display counts for all metrics.

$ ./wc sample.txt
42      67      1337    sample.txt

Handling Input from Stdin:

The program can also handle input from stdin, allowing you to use it in combination with other commands. For example:

$ cat test.txt | ./wc [OPTION]

This command will read the content of test.txt via cat and provide word count statistics.

Handling Manual Input:

You can also manually input text when running the program without a file. Simply run:

$ ./wc

After running the command, you can type or paste the text manually, and the program will provide word count statistics once you press Ctrl + D (Unix/Linux) or Ctrl + Z (Windows) to signal the end of input.

Build and Run

To build the program, you can use a standard C compiler:

$ gcc wc.c helper.c -o wc

To run the program:

$ ./wc [OPTION] [FILE]

wc's People

Contributors

mjiid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.