Thread: help writting code

  1. #1
    Unregistered
    Guest

    Unhappy help writting code

    I have this code to write and does not know how....please help

    Your program takes input from a file it is said to be reading from the file and sends output to a file it is said to be writing to the file.
    The input file may contain any kind of English text. That means,
    anything, but no "funny characters" like Tilde (~) that are not normally
    used in English text. However,! ? % $ , . ; : "' () - & and numbers may occur.
    Your program should
    = Throw away all special characters.
    = Extract all words.
    = Make all words lower case only.
    = Sort all words alphabetically.
    = Remove duplicates.
    = Send the sorted words to the output file.


    thank you

  2. #2
    Unregistered
    Guest
    homework 101 is at a different site. Here, we like to help those who help themselves. Post code with problems you are having and you are likely to get a better response.

  3. #3
    Unregistered
    Guest
    Originally posted by Unregistered
    homework 101 is at a different site. Here, we like to help those who help themselves. Post code with problems you are having and you are likely to get a better response.

    ohh really..I didn't know that...can you tell me how to write it then I will post the problems.........

  4. #4
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    I'm not in the mood to write all your code but...

    Open the file with ifstream I think I'm tired now then use a 2 demsional array I think and put everything in it then weed out things you don't want with a loop and predefined things to take out I'm saying all this expecting you know enough to understand what I'm saying. If you don't I'm pretty sure theres been other posts search the board.
    +++
    ++
    + Sekti
    ++
    +++

  5. #5
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    Hint: Don't get smart with the people here or you won't get any help.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  6. #6
    Here's the code...

    #include <iostream>

    using namespace std;

    void main(void){
    cout>>"DROP THE CLASS, GET A BUSINESS DEGREE";

    }
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  7. #7
    Unregistered
    Guest
    declare a struct called node to hold a string (ie word) a counter to keep track of how many times the word appears in the file and a pointer to the next node

    declare a list class that does an insertion sort using strcmp on the string in the node to sort and a print function to display the string and the counter

    The insertion sort will be passed a string. It will then search the string to see if the passed string is present in the list. If it isn't it will declare a new node using dynamic memory, assign the passed string to the node string using strcpy, assign 1 to the counter, and assign NULL to the pointer. It will then insert the node in the appropriate position. If the passed string is present it will increment the node counter holding the string.


    declare a char to hold each char as it is read in

    declare a buffer of 30 char to hold each word as it is being built
    assign tilde to first element of buffer

    declare int to act as buffer index and initialize to zero

    declare ifstream and open file for reading

    verify file opened successfully

    read in first char outside of loop

    create a loop stopping when you find EOF

    in loop evaluate each char into three cases:
    a) if isalpha(input char)--tolower(input char)--assign input char to buffer if buffer index < 30
    b) if isspace(input char)--if buffer[0] not tilde--add null terminating char to buffer---send buffer to list.insertionSort--assign tilde to buffe[0]--assign 0 to fbuffer index
    c) if not letter or space ignore input char.

    then read in next char before going back to top of loop

    print list after file reading completed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM