+ Reply to Thread
Results 1 to 5 of 5

Thread: Remove a word from sentence using arrays

  1. #1
    Learning Programmer Hawk1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    70

    Remove a word from sentence using arrays

    Well i've made it to the end of my self-taught c++ book and there are a few topics i would like to clear up.

    the first one being how to do remove a word from a sentence using arrays.

    For example, something like this.

    Write a function called deleteit that will delete a word from a sentence.

    Please input a sentence: "i really dont like this assignment"

    The function should take as arguments 2 arrays of chars. The first array will contain the sentence. The second array will contain the word to be deleted.

    please input the word you would like deleted: dont
    Print out the sentence when the function returns.

    Your sentence was: i really like this assignment

    Your function should also return the number of characters deleted if the word was found in the sentence. It should return -1 if the word wasn't found.

    I deleted ____ characters from that sentence.

    I THINK, THATS WHAT its asking for right?

    where do you think the best place is to start on this?
    reps for help like always!
    thanks

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,648
    Blog Entries
    57

    Re: Remove a word from sentence using arrays

    1) Get a new book. You should NOT be using arrays of chars in a C++ course. Use the string class instead.
    2) If this is a homework assignment, make use of the available functions, such as strchr() that are available.
    3) use this site for more info: cstring (string.h) - C++ Reference
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  3. #3
    Learning Programmer Hawk1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    70

    Re: Remove a word from sentence using arrays

    no hw assignments for me, all self taught stuff just because i want to learn.

    whats wrong with using arrays of chars? chars of class isnt till next chapter

  4. #4
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,648
    Blog Entries
    57

    Re: Remove a word from sentence using arrays

    strings are easier to avoid memory problems with, and have a lot of additional functionality that's helpful.
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  5. #5
    Code Warrior dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Age
    19
    Posts
    2,827
    Blog Entries
    8

    Re: Remove a word from sentence using arrays

    If you're still using C strings (arrays of chars), then look into strstr() and memmov().

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Char arrays in C
    By outsid3r in forum C Tutorials
    Replies: 4
    Last Post: 07-28-2009, 03:38 PM
  2. Guess The Word.
    By Paradox in forum Java Tutorials
    Replies: 5
    Last Post: 01-16-2009, 09:48 AM
  3. Finish the sentence:)
    By Donovan in forum Games
    Replies: 9
    Last Post: 10-29-2008, 01:32 PM
  4. Getting ActiveX Control To Send to AbiWord not MSFT Word
    By dranfu in forum Visual Basic Programming
    Replies: 6
    Last Post: 10-13-2008, 09:39 PM
  5. Dictonary Program
    By programmer 101 in forum Java Help
    Replies: 9
    Last Post: 07-01-2007, 01:39 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts