using strcpy to cut one extra space..

This is a discussion on using strcpy to cut one extra space.. within the C Programming forums, part of the General Programming Boards category; i need that if i have "abcd hhh" will become "abcd hhh" onl one space between what two string i ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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, 06: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, 10: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, 03:05 AM

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