Using "STRCPY" to remove a word

This is a discussion on Using "STRCPY" to remove a word within the C++ Programming forums, part of the General Programming Boards category; On a previous test, one question specified that I was to use the STRCPY function to remove the 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,670
    ?????

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 05:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21