Thread: Question about array ?

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    2

    Question about array ?

    For example,i have an array 'char a[15]'
    Now i want to take the content from a[3] to a[8] and copy them to a new array,how can i do it? thanks you all.

  2. #2
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    2
    thanks you but i thought that strncpy just copy from the beginning of the source,how can i copy from the random position ?

  4. #4
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    When you pass it 'a' you're just passing it the address of the first element in the array. You can use the address-of operator to supply strncpy with whichever element you want it to start at.

    EDIT: Alternatively, if you know enough about functions and array indexing, it shouldn't be too difficult to write a function to do this for yourself.
    Last edited by DeadPlanet; 04-18-2010 at 04:55 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Mutli dimensional Array question.
    By fatdunky in forum C Programming
    Replies: 6
    Last Post: 02-22-2006, 07:07 PM
  2. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  4. array question?
    By correlcj in forum C++ Programming
    Replies: 1
    Last Post: 11-08-2002, 06:27 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM