Thread: counts the number of occurrences of the phrase

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    136

    counts the number of occurrences of the phrase

    any help it should be appreciable.
    Last edited by munna_dude; 06-15-2010 at 10:18 PM.

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    You can read in the entire file, read it in chunks or a letter at a time. No matter what, you'll have to scan through it letter by letter, if you find 'h' take a different path of execution, is the next 'e'?
    If not return to your old execution path, if it is, continue until all is found, add 1 to a variable and so on. That's the basic idea I guess, you can do this manually or by using strcmp().

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    136
    Quote Originally Posted by Subsonics View Post
    You can read in the entire file, read it in chunks or a letter at a time. No matter what, you'll have to scan through it letter by letter, if you find 'h' take a different path of execution, is the next 'e'?
    If not return to your old execution path, if it is, continue until all is found, add 1 to a variable and so on. That's the basic idea I guess, you can do this manually or by using strcmp().
    Can you please provide me the code.

    any help it should be appreciabe.

  4. #4
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Read large chunks, it'll probably reduce the amount of random reads, saving a little time.

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Yeah, but no matter what a block is probably going to be read into the cache. Is the file huge? If so, it might make a difference.

    To the OP, your going to face different kind of problems depending on how you do this, for example, how to solve a phrase that crosses two chunks read from a file.

    BTW, no one here is likely to give you a complete working solution, get started and ask specific questions when/if you run into problems.

  6. #6
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587

  7. #7
    Registered User
    Join Date
    Jun 2010
    Posts
    45
    where has OP gone?

  8. #8
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by LordPc View Post
    where has OP gone?
    To work!

  9. #9
    Registered User
    Join Date
    Jun 2010
    Posts
    45
    OP == Original Post
    OPer == Original Poster

    look at the first post. this thread makes no sense

  10. #10
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Ok I see, strange.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Program that counts total prime number?
    By exe101 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 01:18 AM
  2. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  3. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  4. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM