I want to search my char-array for a certain char and replace it with another one. By executing the following code I get this error:
Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
#include <stdio.h>
char replaceCharWithChar(char *string, char toReplace, char replacement) {
while(*string != '\0') {
if(*string == toReplace) {
*string = replacement;
}
string++;
}
return *string;
}
int main() {
printf("%s:", replaceCharWithChar("Hello", 'H', 'T');
return 0;
}