The C Column

Authors

Publication

Pub Details

Date

Pages

See all articles from CATS v8 n3

This month’s program is a simple version of the UNIX utility we (word count). This program reads in a text file and counts all of the lines, words, and characters.

The structure of this program is similar to last month’s program. The section that gets the file is the same. The while statement is the same. It’s the block in the while statement that has changed. One line is different. C has a way of assigning the same value to a number of variables. The line nl=nw=nc=0; sets all of the variables to zero. This way you do not have to write three individual lines to set each variable to zero.

Products

 

Downloadable Media

 

Image Gallery

Scroll to Top