Hi I'm pretty new to C and still don't have a full understanding of pointers, but essentially I'm trying to copy the result of my encryption to the result pointer, and it keeps throwing various errors, currently a segmentation fault. As far as I understand, since result has been initialised as NULL, it can be changed. Any help is appreciated :)
#include <stdio.h>
#include <stdlib.h>
int pointer copy(char **result){
char x='password';
char* p1=&x;
result=&p1;
return 0;
}
int main(void){
char *encrypted_message = NULL;
copy(&encrypted_message);
if(encrypted_message != NULL){
printf("%s\n", encrypted_message);
}
free(encrypted_message)
}