Thread: Need help on finding word count

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    @userxbw:
    There are times where lines can be longer than what you expect to store. For instance in your program the sentence can be up to 300 characters, which is fine, but that means that a 400 character sentence will be truncated...
    no sh it really????? get a grip on life here, that is just stupid nit picking. un realist nit picking here as far as I see. I know I am not going to put in over 300 chars to test it. so slow down.

    the OP has his for 1000 the same can be said about his too. if it is 1001 it is truncated, oh my lets all of you get a grip on yourselves. One programs it to the size they allow to be used. I decided to use 300 because I know I am not about to type in anything over 300 or even close to 300. that is a good ball park number for my purpose. thank you very much.


    once by fgets() just returning as much as it can, leaving the rest to be read later, and again by your code, chopping off the last character in sentence whether it is a \n or not. One of the reasons I showed you the method I did is because unlike strlen(), strcspn() returns the highest subscript if it doesn't find anything.
    yes you did. so now I got another function for checking that. but as I stated in my other post in here to Mr ocpd perfect ... I am not going to repeat it.


    As far as your code goes, the OP's code could have easily been improved as is... maybe check for ' ' or the first character in the word before starting the inner loop, instead of only looking for the first character in word... this makes it so spaces are taken into account.

    Your solution does too much. It's just not necessary to do it the way that you are.
    I never said it was and that is your option I just grabbed a thought, it was. get each word separately then check it against the search word, and it does that. does it have room for improvement> I do not care at this moment in my life. It was just something I did to see if I could. and I accomplished it. time to move on. it is and was not intended for the OP.

    my code was not even intended for the OP I was doing nothing to it other then stating what I found. period. the function I wrote was me just trying to figure out a different way for doing it. and nothing more. It was never intended to be used in anything. period. I just posted it.


    Your solution does too much. It's just not necessary to do it the way that you are

    really? are you serious? it removes each word one at a time looks at it against the other word if match count if not don't count I guess I could have had it look at each word by one letter at a time, then it too can be said that it does too much and is not necessary as well.

    mine works. it does exactly what I wrote it to do. so yes it is good code.

    is there another way to grab each word separately? I am sure there is and if so then woo hoo for that too.
    Last edited by userxbw; 11-13-2017 at 07:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Uppercase/Lowercase/Word COunt/Char count
    By Charak in forum C Programming
    Replies: 7
    Last Post: 02-23-2011, 08:16 AM
  2. word count help
    By regimental in forum C Programming
    Replies: 7
    Last Post: 03-05-2010, 08:47 AM
  3. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM
  4. word count
    By gokila in forum C Programming
    Replies: 2
    Last Post: 02-19-2002, 01:35 PM

Tags for this Thread