|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I would like to know how I would go about copying one string from another, with the added option of stating from where I want to copy.
I know that you can use the strncpy() function to specify how many chars you want to copy. But I don't want to copy from the start of the string neccesarily. I might want to copy from char no 5. Hope somebody can help Thanks dries |
|
#2
|
||||
|
||||
|
In that case you'll still be using strncpy; instead of passing a pointer to the start of the source string, you'll pass a pointer to the fifth char in the string:
Code:
char *src, *dst; . . . strncpy (dst, src + 5, strlen(s) + 1 - 5; Watch out for overstepping boundaries though; that's nasty...
__________________
"A poor programmer is he who blames his tools." http://analyser.oli.tudelft.nl/ |
|
#3
|
|||
|
|||
|
for String objects you can use this:
theString.copy(str, x, n); // Compares theString and str, starting // at position x, and continuing for n // characters. justin_dago |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > copying a string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|