Thread: using strcpy to cut one extra space..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    using strcpy to cut one extra space..

    i need that if i have "abcd hhh"
    will become "abcd hhh" onl one space between

    what two string i need to copy
    what is the indexes of each string.

  2. #2
    Resu Deretsiger Nightowl's Avatar
    Join Date
    Nov 2008
    Location
    /dev/null
    Posts
    186
    You'll want strncpy instead of strcpy, I believe. No?
    Do as I say, not as I do . . .

    Experimentation is the essence of programming. Just remember to make a backup first.

    "I'm a firm believer that <SomeGod> gave us two ears and one mouth for a reason - we are supposed to listen, twice as much as we talk." - LEAF

    Questions posted by these guidelines are more likely to be answered.

    Debian GNU/Linux user, with the awesome window manager, the git version control system, and the cmake buildsystem generator.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    Quote Originally Posted by Nightowl View Post
    You'll want strncpy instead of strcpy, I believe. No?
    I would beleive memmove should be used - strcpy has nothing in the description that says that it could always copy over itself
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    so what indexes to use in the strcopy function
    what two sub strings do i take?

  5. #5
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    if i would do it withouth str copy then i would start copying every next cell to the current one
    from the place where i got a copy
    but strcopy needs two equal length string

    ??

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cant get strcpy to work
    By jtullo in forum C Programming
    Replies: 2
    Last Post: 05-05-2008, 04:21 AM
  2. Process memory space
    By barboris in forum C++ Programming
    Replies: 6
    Last Post: 04-25-2008, 11:35 PM
  3. malloc allocates the same space in the memory
    By myle in forum C Programming
    Replies: 23
    Last Post: 11-20-2007, 07:52 PM
  4. How do I tell what character is in a space?
    By Kyoto Oshiro in forum C++ Programming
    Replies: 2
    Last Post: 03-27-2002, 11:11 PM
  5. ARGH! (argc and argv too!) HD Space!!!
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 12-05-2001, 04:05 AM