Thread: Using "STRCPY" to remove a word

  1. #1
    Polar Fuzz
    Join Date
    Oct 2003
    Posts
    36

    Using "STRCPY" to remove a word

    On a previous test, one question specified that I was to use the STRCPY function to remove the word "Not" from the string:

    char s [] = "This Is Not A Happy Day";

    We were to use only a ONE line command but I am assuming that I could nest other functions inside the STRCPY function.

    Anyone know?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    ?????

    strcpy()

    gg

  3. #3
    Polar Fuzz
    Join Date
    Oct 2003
    Posts
    36
    Yes, the question stated to use the "string copy" (STRCPY) function to remove a word from a string. I though it was unusual.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Well the obvious
    Code:
    strcpy( &s[8], &s[12] );
    This may be the answer your tutor is looking for, but its the wrong answer. strcpy() is not defined on overlapping string copies such as this. It may work for you, but the effect is not guaranteed.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  4. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  5. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 06:44 PM