strings

This is a discussion on strings within the C Programming forums, part of the General Programming Boards category; i have a string name str i want to put the char's in places 3-6 in another string called st. ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    1

    strings

    i have a string name str
    i want to put the char's in places 3-6 in another string called st.
    how do i do that?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    is this a string or a char*? you can access the elements in the 'string' by their indices (ie: str[2] = st[0]'). you can overwrite the characters there, but you cant resize the length of your char*

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Code:
    strncpy(st, str+3, 4);
    st[4] = '\0';

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 02:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 07:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM

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