Link C Programs
Learn how to link two C files
Have you ever wondered how to link multiple source files in C ? Well wonder no more, I will show you all easy steps to link your own C-Program source files.
Step 1: Create Your Two C-Program Source Files
First thing to do is create your two programs. Here I will name one file as “File1.c” and the other “File2.c”. File1.c will contain our main function, and call our hello() function. File2.c will contain the actual function definition, which provides the actual body of the function.
File1.c
int main(void) {
hello();
return 0;
}
File2.c
#include <stdio.h>
void hello(void) {
printf("Hello, World!\n");
}
Step 2: Save Both Files In The Same Location
Really you could put them in different locations, but you have to remember both locations. In this article I will save both files on my Windows Desktop.
C:\Users\<user_name>\Desktop
Step 3: Open Command Prompt And Run These Commands
Now, open your command prompt.