how to fix segmentation fault core dumped in this code i saw example code online and 5122613

How to fix segmentation fault(core dumped) in this code I saw example code online and wanted to add some extra lines toplay around with the program. Instead of passing the same characterpointer message i wanted to get the message string from user input.I also added a line so i can see the decrypted message but thisline seems to throw segmentation fault(core dumped) error when irun it. Here is code: #include


#include char* encryptPass(char* message, char* key) {

    size_t messagelen = strlen(message);

    size_t keylen = strlen(key);     char * encrypted = malloc(messagelen+1);     int i;

    for(i = 0; i

        encrypted[i] =message[i] ^ key[i % keylen];


    encrypted[messagelen] = ‘ ‘;     return encrypted;

} int main() { /*char* message = “test message”;*/

char* message;

char* key = “abcasF3243adFx”; printf(“enter message to encrypt:n “);

scanf(“%p”, &message);     char* encrypted = encryptPass(message,key);

    printf(“%sn”, encrypted); char* decrypted = encryptPass(encrypted, key);

printf(“%sn”, decrypted);     free(encrypted);     return 0;

} Please show corrected code and output. Explaination alsoappreciated ty . . .

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now