C + + Word Count Publisher

Source: Internet
Author: User

Some time ago, imitating the WC program under the Linux system, a similar WC program was implemented in the Windows system environment, but it was targeted to the source code files of C/c++,java and other styles.

This WC program can count the number of characters, the number of words (excluding comments) and the number of lines, in addition to the number of empty rows, lines of code and number of comment lines, and even statistics in the same directory (including subdirectories) of the suffix name of the file (support ' * ' wildcard character).

The WC function was originally used in the Command Prompt window, just like Linux, with the addition of a graphical user interface that allows you to select files by mouse, and to count selected files (all eligible files under the directory selected for statistics are not currently supported).

The WC program in command-line window mode is a compiled link from Visual Studio 2013, and the WC program for the graphical user interface is edited using Qt.

WC source code and publisher download link address: Https://github.com/xucongandxuchong/WC

Each function is encapsulated as a standalone API function and has a corresponding fault tolerance mechanism. After encapsulation, each function has been unit tested, with the possible error parameters to detect, each function is normal execution. But when it comes to counting words, the results are incorrect. Then, using a step-by-stage and gradual combination of debugging methods, found that there is a logical loophole. I used to focus on using STL instead of making the structure too complex, which led to the emergence of this situation. So, I converted to the C-language process-oriented thinking, using a character-by-word traversal, in the Traverse to count the number of words, that is, to meet the characteristics of the word occurrence of the number of cases.

Run the way and effect as shown:

Graphical user interface programs can also be run separately.

Note: This WC procedure is purely original, reproduced please indicate the source.

C + + Word Count Publisher

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.