HW help

This is a discussion on HW help within the C++ Programming forums, part of the General Programming Boards category; I really need some help with this hw assignment. I'm not sure how to write these fuctions... Write a program ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    5

    HW help

    I really need some help with this hw assignment. I'm not sure how to write these fuctions...

    Write a program to process text files. The program should read a text file and output the data in the file as is. The program should also output the number of words, number of lines, and the number of paragraphs.

    You must write and use the following functions.

    a) initialize: This function initializes all the variables of the function main

    b) processBlank: This function reads and writes blanks. Whenever it hits a nonblank(except whitespace characters), it increments the number of words in a line. The number of words in a line is set back to zero in the function updateCount. The function exits after processing the blanks.

    c) copyText: This function reads and writes the nonblank characters. Whenever it hits a blank, it exits.

    d) updateCount: This function takes place at the end of each line. It updates the total word count, increments the number of lines, and sets the number of words on a line back to zero. If there are no words in a line, it increments the number of paragraphs. One blank line(between paragraphs) is used to distinguish paragraphs and should not be counted with the number of lines.

    e) printTotal: This function ouputs the number of words, number of lines, and number of paragraphs.

    Your program should read data from a file and send output to a file. Do not use any global variables. Use the appropriate parameters to pass values in and out of the functions described above.

    Any help would be greatly appreciated. Thanks.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    Ffirst write an empty program with only a main function. Then make sure it compiles. Then, one at a time, add each of the functions mentioned above with void return value and no parameters, compiling each one to make sure there are no typos. Then, for initialize, add the appropriate parameters but don't do anything with them. Add a call to this function from main passing the appropriate variables. Make sure it compiles. Then slowly implement initialize.

    When you are done implementing initialize, move on to the next one. Maybe before getting in too deep, write out on paper what kind of variables you will need, and what variables each function will need. Since there are no global variables, you will create all your variables in main and pass them to each function as needed. Having the flow written on paper will help you as you do each step.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    5
    I'm still confused on how to write functions b) c) and d).

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    Then show what you've tried for one of them (remember do one at a time and make sure it is working) and maybe somebody will be able to help you.

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    Yeah, man. You're asking us to do your homework for you.

    Try it yourself, see if you can get it to work. If you can't, show us the code you wrote and we'll help you from there.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing HW registers using bit fields and UINT32
    By samdomville in forum C Programming
    Replies: 4
    Last Post: 12-10-2008, 12:00 PM
  2. Replies: 10
    Last Post: 12-05-2008, 11:47 AM
  3. ioctl request to get the HW address
    By threahdead in forum Linux Programming
    Replies: 7
    Last Post: 01-03-2008, 12:34 AM
  4. Help with HW
    By DontBugMe in forum C++ Programming
    Replies: 7
    Last Post: 04-11-2006, 10:45 AM
  5. Hw
    By SAMSAM in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 05-23-2003, 06:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21