Linking Multiple .C Modules and malloc()
Posted on 1997-05-11
I've been writing a program recently, and I found that it got too big to manage all in one .C file. However I've run into a problem trying to link all of the files together. I'm using Turbo C, and defined all of the .C files as part of a project. But when I tried to link the program, (using the "Make" option) I got tons of "Undefined symbol '...' in function ..." errors. I've got all my #include files defined in the main module (the one with the main() function), and I don't think the rest of the modules are seeing them. But when I put the include files in all of the modules, I get "Duplicate symbol ..." (or something like that) errors. How do I get the linker to recognise the include files for all of the modules?
Also, how would I go about allocating memory for a 250 element array of structures? I tried:
soldier = malloc(sizeof(soldier) * 250));
where 'soldier' was defined as:
struct soldier *soldier;
I've probably made some pointer mistake, but I'm new to C and I'm still a little puzzled with all the different pointer operators (*, &, etc.). Any help would be GREATLY appreciated as I can't go any farther with my program without clearing these problems up. Thanks...