Course Solutions Uncategorized (Solved) : Keep Recieving Segmentation Fault Core Dumped Run C Program Causing Issue Fix Include Incl Q28439614 . . . .

(Solved) : Keep Recieving Segmentation Fault Core Dumped Run C Program Causing Issue Fix Include Incl Q28439614 . . . .

 

I keep recieving a Segmentation fault (core dumped) when I runthe c program. What is causing the issue and how can I fix it?

#include<stdio.h>
#include<string.h>

int main()
{
       FILE *fpt = fopen(“test.txt”,”r”);
    char str1[15], str2[15];
       int read;

    printf(“Enter the search string: “);
   fgets(str1, 15, fpt);

    while(fscanf(fpt, “%15s”, str2) == 1)
    {
       read = strlen(str2);
             if(strncmp(str1, str2, read)==0)
             {
                   printf(“Found:%s”, str2);
             }
    }
    fclose(fpt);
    fgets(str1, 15, fpt);
}

Expert Answer


An answer will be send to you shortly. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post