arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sibat
    New Member
    • Jul 2008
    • 1

    arrays

    How to write a C program that will take input of a line of text ended by a new line ('\n') and count the number of characters,word s,sentences in that string, and print the totals.
    (Assume the input text will not exceed 100 characters.)
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    *bump* I found this post in the C/C++ Articles section where it doesn't belong.

    kind regards,

    Jos

    Comment

    • Nepomuk
      Recognized Expert Specialist
      • Aug 2007
      • 3111

      #3
      Hi sibat! Welcome to bytes.com!

      To read a line of input up to a '\n' character, use getline.

      To count the characters, words, sentences, etc. you should know, what characters a word or a sentence can be finished with (so, what character comes next?) and a that string is a char array which ends with a binary 0 ('\0').

      That should be enough for you to solve the task yourself.

      Greetings,
      Nepomuk

      Comment

      • bvmpriya
        New Member
        • Jul 2008
        • 8

        #4
        Hi Sibat,
        You can use some buffer array with ur maximum size of characters and get ur input using gets something like that in the array....
        You can check whether the buffer value is \n if so count it as new line, and do all the comparisions u need...
        I think this might work......

        Regards,
        Priya

        Comment

        Working...