This is my main.c
:
#include <stdio.h>
void changeStuff(char *stuff){
stuff= "Hello everyone";
}
int main(int argc, char **argv) {
char *stuff;
changeStuff(stuff);
printf(stuff);
return 0;
}
When I build this, I get this warning:
warning: ‘stuff’ is used uninitialized in this function [-Wuninitialized]
When I run this program, nothing is printed.
Since it does not seem possible to define a char*
with no value after it has been declared, how do I change the value of a char*
passed to a function?