if(letter>=inital && letter<=end)//if any of the chara in the array equals the chara that is to replaced then
{
newresult+=c[i];//changes the chara
}
In the above code, you are comparing a character to an integer, rather than an int to an int (the result is a comparison of the char ascii value to the int). You should rather do the comparison to 'i' rather than letter. An easier way overall is to create a char array of the length of the substring, then fill in the array by iterating through the parameter string starting at the initial and ending at the end, returning a new string created with the character array