Thread: function that modifies a string

  1. #1
    Registered User
    Join Date
    Oct 2003

    Question function that modifies a string

    i have to write a small funtion that modifes a string by replacing every occurence of the letters foo by aaa. an example of the string is "food fool" and should become "aaad aaal". i've written this function and i just want to know if i got it right because i'm not that good when it comes to functions. thanks
    void censor(char s[])
       int i; 
       for(i=0; s[i]!='\0'; i++)
          if (s[i]=='f' && s[i+1]=='o' && s[i+2]=='o')
       return a; 

  2. #2
    Join Date
    Sep 2003
    >i just want to know if i got it right
    Does it work? If it works with any test cases you come up with, you got it right.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM