In golang, what's the easiest way to replace a char literal in a string?
Here's the C code, where we replace the whitespace with '3':
#include <stdio.h>
#include <string.h>
int main(){
char input[] = "Look ma no hands";
printf("Input \"%s\" ", input);
for (int i = 0; i < strlen(input); i++){
//printf("input[%d] is %c
", i, input[i]);
if ( input[i] == ' ' ){
input[i] = 3;
}
}
printf(",converted to :%s
", input);
return 0;
}
The output:
$ ./a.out
Input "Look ma no hands" ,converted to :Lookmanohands
How can we do this in golang?