How can I replace characters in a string using a pointer? (in c code)
Here's my code:
#include <stdio.h>
#include <string.h>
unsigned char code[] = "Hello world!\n";
main()
{
printf("String Length: %d\n", strlen(code));
printf("Original String: %s\n", code);
char &code[7] = "W";
char &code[8] = "a";
char &code[9] = "l";
char &code[10] = "e";
char &code[11] = "s";
printf("New String: %s\n", code);
}
'W'in"Hello World"is 6. Although you would notice that very quickly with this program after fixing the syntax.memcpy(&code[6], "Wales", 5);