return anything, but rather changes the string itself. Why would I be getting a bus error 10?
void replaceChar(char *src, char oldChar, char newChar){
//get length of source string.
int length = 0;
length = (int) strlen(src);
char *newSrc = (char *)malloc((length + 1) * sizeof(char));
//checks and manipulates the string.
int i;
char c;
for (i = 0; i < length; i++){
if (src[i] == oldChar){
src[i] = newChar;
}
}
}
I feel like maybe I can't overwrite existing characters in a string, but I don't know how else to implement this without returning anything, which I am not allowed to do.

New Topic/Question
Reply


MultiQuote


|