frankcollins3 / mergedoctor

mergeMD: take for instance 2 alike in name markdown files -> delete data from 1 merge into 1 new .md file
0 stars 0 forks source link

block of code tasked with handling userinput on whether original files deleted prevents merge [9:11pm] #13

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

this block of code that handles the inputs that ask the user which files they'll be deleting: doesn't prevent the file being created but does prevent the merge from happening. Only moments ago it would create the merge file, if user pressed 1 then file1 deletes. Presses 2 file 2 deletes. But not both.

    if (fp3 != NULL) {
        char delete;
        printf("want to delete the original files? \n");
        printf("enter 1 into the input to delete file_1 \t"); printf("enter 2 into the input to delete file_1 \n"); 
        scanf("%[^\n]", &delete);
            char* file_path_1_again = get_file_path(user, file1);
            char* file_path_2_again = get_file_path(user, file2);
            file_path_1_again[strcspn(file_path_1_again, "\n")] = '\0';
            file_path_2_again[strcspn(file_path_2_again, "\n")] = '\0';
            printf("path1:\t %s", file_path_1_again);
            printf("\n");
            printf("path2:\t %s", file_path_2_again);
            printf("\n");

        if (delete == '1') {
            printf("were in the 1");
            remove(file_path_1_again);            
        }
        if (delete == '2') {
            printf("were in the 2");
            remove(file_path_2_again);
        }
        if (delete == '3') {
            printf("were in the 3");            
            remove(file_path_1_again);
            remove(file_path_2_again);
        }        
        }

Now: for some reason if I uncomment out this code, the files stop merging. The file is successfully created though. Just before though I was having no problems with the code creating but not deleting.

👍 Now, resulting merge file, successfully put into scope of [/Users/Desktop] 👎 doesn't have populated data from the file 1 and file 2.

[9:11pm]

frankcollins3 commented 1 year ago

posting issues really helps and gets the brain thinking a little bit. first proposed approach which I believe might work is to:

dismantle all of these options. Just make an input ask if the user wants to delete the file1 have another input after that step ask if the user wants to delete file_2.

No double deletion. No option 3

[9:14pm]