Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

the following is my code in main.c when i compile the whole program i get no err

ID: 3632430 • Letter: T

Question

the following is my code in main.c when i compile the whole program i get no errors and an a.out but then i try to run it with a file i get segmentation error. please help!

#include <stdio.h>
#include "my.h"
int **a;
int rows, cols,j,k;
FILE* p;
int i;
int main(int argc, char* argv[])
{
fopen(argv[1], "r");
fscanf( p, "%d", &rows);
fscanf( p, "%d", &cols);

a = (int**)calloc (rows, sizeof(int*));
for (i = 0; i <rows; i++)
{
a[i] = (int *)calloc (cols, sizeof(int));
}

for (j=0;j<rows; j++);
for(k = 0; k < cols; k++)
{
fscanf(p, "%d", &a[j][k]);
}
printme(a,rows, cols);
oddvalues(a,rows, cols);
oddlocations(a, rows, cols);
countoddrows(a,rows,cols);
addrows(a,rows,cols);
findfirstsmall(a,rows,cols);
findlastlarge(a,rows,cols);
addcolumns(a,rows,cols);
averagecolumns(a,rows,cols);
return 0 ;
}

Explanation / Answer

You have not given the code of my.h. One solution is restart your system than again run your program.It may help you.