int main(argc, argv)
int argc;
char *argv[];
{ OMG you mean some people still code like that??? I haven't seen that style of coding for probably 20 or more years. Is your compiler really that ancient? Even the C standards don't recommend that original K&R style. I see you didn't use that style anywhere else so why in main() ?
int main(int argc, char* argv[])
{
I know my comments don't help solve your problem, but it will take some time to sift through your code.