So, I went back to my last working version of the program, then i went through and changed some values of arrays, but I incremented them all by the same amount so it should work the same way. Of course, a segmentation fault occurs at the beginning of the program.
Here is my main:
Code:
int main(){
//printf("main start\n");
struct hostfreq hostCon[1000001];
//printf("host con built\n");
int i = 0;
while(i<=1000000){
hostCon[i].freq=0;
i++;
}
addHosts(hostCon);
i = 0;
//printf("before copy\n");
sort(hostCon);
/*for(i; i<=1999; i++){
printf("Host name %s : %i \n i is %i\n", hostCon[i].hostName, hostCon[i].freq, i);
}*/
//printf("program complete\n");
return 0;
}
The gdb output looks like this:
Code:
Starting program: ***/host
Program received signal SIGSEGV, Segmentation fault.
0x08048a4d in main () at hostanalysis.c:145
145 hostCon[i].freq=0;
the structure code looks like this:
Code:
struct hostfreq{
int freq;
char hostName[255];
};
Any suggestions? Thanks