15
I want to call a function and I want that function to change the contents of a string or array in the program to a constant.
Psuedocode:
some_array = "hello"
print some_array #prints "hello"
changeArray(some_array)
print some_array #prints "bingo"
I know I have to pass the pointer to that function. Here's what I wrote,
void changeArray(char *arr){
arr = "bingo";
}
int main(int argc, const char* argv[]){
char *blah = "hello";
printf("Array is %s\n",blah);
changeArray(blah);
printf("Array is %s\n",blah);
return EXIT_SUCCESS;
}
How can I do this?