Hey all,
I've searched far and wide for an answer to this but have yet to find a case which is the same as mine...
Basically I have a string (indata), eg "1234" and I want to be able to copy the "23" from this and store it in a seperate string (oldadd). I have tried strcpy but it only seems to want to copy the entire string, not just the single element which I want.
Originally I had the following (left out declarations since I'm being lazy here):
With the intention of copying the 2nd char of the string indata to oldadd and then sticking the 3rd char onto the end of oldadd later. This is the only way I can think of doing it, I can't use a strstr or strchr because the little bit I want will always be different however I know that it will always be the 2nd and 3rd character of the indata string.Code:indata = "1234"; strncpy(oldadd, indata[1], 1); strncat(oldadd, indata[2], 1);
Thanks for any help, I hope this hasn't been answered somewhere else which I've missed :S
pgcrooks