my task is to remove all the comments from a .c file and save the content in another .o file.
Given file:
// Sums two integers.
// Parameters: a, the first integer; b the second integer.
// Returns: the sum.
int add(int a, int b) 
{
    return a + b; // An inline comment.
}
Should look like:
int add(int a, int b) 
{
    return a + b; 
}
I have been trying this multiple times and I reached this state:
#include <stdio.h>
    int main(int argc, char **argv)
    {
        FILE * fPtr;
        fPtr = fopen("test.o", "w");
        char line[300];
        FILE *file = fopen("math_functions.c", "r");
        if (file == NULL) {
            printf("Error: Could not open %s!\n", "math_functions.c");
            return -1;
        }
        else {
            while(fgets(line, 300, file)) {
                int len = strlen(line);
                char helperLineArray[300];
                for (int i = 1; i < len; i++) {
                    if (line[i] == '/' && line[i-1] == '/') {
                        break;
                    }
                    else 
                    {
                        helperLineArray[i-1] = line[i-1];
                    }
                }
                fputs(helperLineArray, fPtr);
            }
        }
        return 0;
    }
Thank you in advance!