Hey, from the code supplied I can't really tell what you are doing, where does pFields come from?
A string in c is just a char array with a null when the string stops which may be anywhere in the array. assuming what is in pFields is a string we can change a character simply by setting it:
pFields[1][1] = 'n';
this would change the second character of the string at pFeilds[1] to a n, again assuming the string in more then 2 characters long.
so with this information, all we have to do is loop over each character in the array checking if its the token you want to replace, and if it is replace it, until we find a null(0) then stop.
int i = 0; //set i to 0
while(pFields[1][i] != 0){ //check if we reached the end of the string (current char is 0)
if(pFields[1][i] == '<'){ //check if the character is the token to be replaced
pFields[1][i] = ' '; //if it is replace it
}
i++; //increment the index variable
}
Quote:
pFields[1] returns nothing if there is a space in the string
not sure what you mean by that, if pFields[1] is 0, as pFeilds is an array of pointers to strings, it means that there is no string.
hope this helps and I didn't totally misunderstand what your question was,
I want to replace a character in this array item
pFields[1]
Lets say the array item contains "Hello<World"
I want to replace the arrow with a space so it ends up looking like this
"Hello World"
How would i go about doing that?
Gosh c++ is crazy >.<