I have a code like following -
Value = "Current &HT"; //this is value void StringSet(const char * Value) { const char *Chk = NULL; Chk = strpbrk(Value,"&"); if(Chk != NULL) { strncpy(const_cast<char *> (Chk),"&",4) } } In above code I would like to replace "&" from Value with "&.It works fine if I have "&" single character but in current case strpbrk() return "&HT"and in below strncpy whole "&HT"is replaced.
Now I would like to know methods by which I can only replace a single character from a string.
std::stringfor this? It has areplacefunction.