I am trying to create a function that would allow me ask a user for files. When I tried printing the addresses using "%p", fileGot, Buffer and *userFileNameInput all have the same address stored. However, when I try to verify the value in the main function, the pointer is NULL. Can someone help explain why this is, and what would be a better way to go about it?
int main()
{
char *fileGot;
fileGetter( &fileGot );
printf("filegot: %s\n" , fileGot);
return 0;
}
void fileGetter( char **userFileNameInput )
{
char buffer[100];
*userFileNameInput = buffer;
printf("enter file: \n");
scanf("%s" , buffer);
}