need to do a search and change it to something if it matches. occurs in the second comment. 0x7994FF5C (ucrtbased.dll)

-1

void changeInfo() {
    char stf[255] = { 0 }, rtf[255] = { 0 }, str[255] = { 0 };
    FILE* file = NULL;
    fopen_s(&file , "data.txt", "r+");
    printf("Enter text to find: ");
    cin>>stf;
    fgets(stf, 255, stdin);
    stf[strlen(stf) - 1] = '\0';
   printf("Enter text to replace: ");
    fgets(rtf, 255, stdin);
   rtf[strlen(rtf) - 1] = '\0';
    while (fgets(str, 255, file) != NULL)
    {
        char* tmp_ptr = strstr(str, stf);
        while (tmp_ptr != NULL)
        {
            char tmp_str[255];
            strcpy(tmp_str, tmp_ptr + strlen(stf));
            //strcpy((str + strlen(str) - strlen(tmp_ptr)), rtf);
            strcat(str, tmp_str);
            tmp_ptr = strstr(str, stf);
        }
        printf("%s", str);
    }
    fclose(file);
    getchar();
}

need to do a search and change it to something if it matches. occurs in the second comment. Exception thrown at 0x7994FF5C (ucrtbased.dll) in Project11.exe: 0xC0000005: Access violation reading location 0x30303032.

c
asked on Stack Overflow May 9, 2020 by qwerty • edited May 9, 2020 by qwerty

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0