Computing.Net > Forums > Programming > c++ program help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

c++ program help

Reply to Message Icon

Name: walkities
Date: January 30, 2003 at 17:03:20 Pacific
OS: XP
CPU/Ram: P4/512
Comment:

Trying to write a program but am stumped. Im trying to generate a command line utility that will generate a series of stats about the contents of a target textfile. Stuff like Number of lines, number of words etc etc.

The Program will take either one (1) or two (2) command line arguments.

1. The first (required) argument is the path and name of the text file for which statistics will be collected.


I was thinking of a structure but am a little confused how they work, could someone give me some suggestions on how to attack this.



Sponsored Link
Ads by Google

Response Number 1
Name: Lucixir
Date: January 30, 2003 at 19:37:59 Pacific
Reply:

You are asking for C++ help but refering to C struct.

If you wanted to do this in C++ you would need to use classes and figure out a way to hold your data in a class.

Im not sure of the details of your project so I cant quite give you more detail or an example of what I mean, but I would look at using classes if I were you and not structs.


0

Response Number 2
Name: drewshaver
Date: January 31, 2003 at 14:54:31 Pacific
Reply:

structs and classes are essentially the same. Only difference is structs default to public and classes to private...however generally classes are used for more complicated things.

I do not think that the use of a class here is necessarry...ur problem seems fairly simple.

Getting the number of lines would be easy, just utilize the EOF and getLine functions of fstream.

Number of words would be ez as well...simply count the number of spaces that have no space to their left (to account for double spaces after periods, colons)

and your done!



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Batch Help About Borelli34



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: c++ program help

C programming help www.computing.net/answers/programming/c-programming-help-/6364.html

C Programing HELP www.computing.net/answers/programming/c-programing-help/13625.html

c program help www.computing.net/answers/programming/c-program-help/8129.html