Thread: need help please! getchar, putchar, etc.

  1. #1
    sue
    Guest

    need help please! getchar, putchar, etc.

    Hello everyone
    If anyone can help me with my lab problem, it will be greatly appreciated. I hope it's not a dumb question! Here it is:

    >>This program will “pronounce” an ordinary sentence with a lisp. Prompt the user to enter a sentence. Read the characters one at a time using getchar(), until a period appears. As they are read, convert everything to lower case and test for occurrences of the character ‘s’ and the pair “ss”. Replace each ‘s’ or “ss” by the letters ‘t’ and ‘h’. Print the converted message using putchar().

    For example, given the sentence “I see his house.”, the output would be “I thee hith houthe.”<<

    I am not sure how to do this program code?? I know how to use getchar and putchar to print out how many spaces are in a sentence but not how to change things in the sentence and print out the changed sentence, any help would be very nice! : )

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    read with getchar() as instructed.
    use tolower() from ctype.h to make lowercase.
    check to see if s. if s then insert into your buffer t else insert read char
    read next char. check for s. if s insert h else insert h and read char
    end of loop.

    your buffer contains lispy string.that can be outputted with putchar() as instructed. more help requires original code.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculator using getchar, putchar
    By arlen20002000 in forum C Programming
    Replies: 5
    Last Post: 03-26-2008, 10:37 AM
  2. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  3. Can anybody take a look at this?
    By TerryBogard in forum C Programming
    Replies: 10
    Last Post: 11-21-2002, 01:11 PM
  4. Replies: 2
    Last Post: 01-10-2002, 07:42 PM