|I'm not sure what the program is meant to do, but you have the signature of "main()" all wrong. It should be|
int main(int argc, char *argv)
and don't forget that argv is the program name.
The best way to track down segmentation faults is to compile with the -g flag and then run the program under gdb. Set a breakpoint at "main" and single-step through until the program fails.