• + 0 comments

    The C code is almost blank, just the main function and not the strings_xor function. So i had to create the code by myself so of course it doesn't work since the main condition isn't satisfied (just 3 lines)...

    C implementation :

    #include <math.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <assert.h>
    #include <limits.h>
    #include <stdbool.h>
    
    char * strings_xor(char * input1, char * input2)
    {
        char * answer = malloc(strlen(input1) * sizeof(char));
        
        for (int i = 0; i < strlen(answer); ++i)
        {
            answer[i] = '0';
        }
        
        // We read the console
        
        scanf("%s\n",input1);
        scanf("%s\n",input2);
        
        // We calculate the XOR relation between the inputs
        
        for (int i = 0; i < strlen(input1); ++i)
        {
            if (input1[i] != input2[i])
            {
                answer[i] = '1';
            }
            if (input1[i] == input2[i])
            {
                answer[i] = '0';
            }
        }
        
        return answer;
    }
    
    int main()
    {
        // We create three pow(10,4)+1 length string variables to stock the inputs and to create the answer
        
        char * input1 = malloc((pow(10,4)+1) * sizeof(char));
        char * input2 = malloc((pow(10,4)+1) * sizeof(char));
        
        char * answer = strings_xor(input1,input2);
        
        // We display the answer
        
        printf("%s",answer);
        
        free(input1);
        free(input2);
        free(answer);
    	`
        
        return 0;
    }