I am quite new to C, and for some reason, I can't get this following program to work as intended. Can someone help me figure out why? Thanks in advance.
Code:#include <stdio.h>
#include <string.h>
void foo(char* source) {
char random[] = "random";
source = (char*)strdup(random);
}
int main() {
char* source;
foo(source);
printf("%s\n", source); //Should say "random"
return 0;
}