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.
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.
thanks you but i thought that strncpy just copy from the beginning of the source,how can i copy from the random position ?
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.