I have try set one of array item to specific value. The program is compiled but when I execute it return segfault.
Here is the code:
#include <stdio.h>
void Debug(unsigned char* str, char simbol, char size);
int main() {
Debug((unsigned char*)"DEBUG: message: x\r\n", 'e', 40);
return(0);
}
//this function I try to replace all occurrences of x with simbol value 'e'
void Debug (unsigned char* str, char simbol, char size){
char i;
for (i = 0 ; i < size ; i++){
if( str[i] == 'x' ){
str[i] = simbol;
}
}
printf ("%s\n", str);
}
Thanks in advance for any help !