All pastes #976230 Raw Edit

Someone

public c v1 · immutable
·published 2008-04-08 00:24 UTC
rendered paste body
int main(int argc, char *argv[]){	FILE *fd;	double *d;	int *p;	heap* h;	int n = 0;	int m = 0;	int startnode = 0;	int i = 0;	if(argc < 2)	{		printf("Must be called with a filepath as first argument.\n\r");		return 1;	}	fd = fopen(argv[1], "r");	if(fd == NULL)	{		printf("Failed to open file %s with code %d\n\r", argv[1], errno);		return 1;	}	char line[256];	// get number of nodes	fgets(line, 255, fd);	sscanf(line, "%d", &n);	// get starting node	fgets(line, 255, fd);	sscanf(line, "%d", &startnode);	// read line pairs. This takes two passes as we need to know the size of the array first.	printf("lol1\n");	while(fgets(line, 255, fd) != NULL)	{		m++;	}	printf("lol2\n");	h = startheap(m);	printf("lol3\n");	d = calloc(m*sizeof(double), 0);	printf("lol4\n");	p = calloc(m*sizeof(int), 0);	printf("lol5\n");	for(i = 0; i < m; i++)	{		d[i] = INT_MAX;	}	printf("lol6\n");	adjlist **adjnodes = calloc(sizeof(adjlist *)*n, 0);	for(i = 0; i < n; i++)	{		adjnodes[i] = NULL;	}	rewind(fd);	printf("lol7\n");