xiuxiull
asked on
How can I copy the string from a specified position in C?
In order to rotate the 2 last charaters in a word, I use the following way
For example, s[] = "Hello";
I would like to copy "lo" to another array with strcpy and then use strcat to concatenate the string "Hel" after "lo" to form "loHel".But I can only copy the whole string to another array, I don't know how to specify an exact position. Thanks, I'm just newbie in C.
For example, s[] = "Hello";
I would like to copy "lo" to another array with strcpy and then use strcat to concatenate the string "Hel" after "lo" to form "loHel".But I can only copy the whole string to another array, I don't know how to specify an exact position. Thanks, I'm just newbie in C.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
xiuxiull:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
char orig[] = "Hello"
char newStr[6];
memcpy(newStr, orig[strlen(orig)-2], 3);/* 3 to copy the null*/
memcpy(newStr[2], orig, strlen(orig)-2);