To organize code in multiple files split above example in main.c, hello.c and hello.h. Content of main.c;
#include "hello.h" int main() { hello("world"); return 0; }
Header file contains declaration of the function hello, content of hello.h;
void hello(const char* name);
Implementation of hello function in hello.c;
#include <stdio.h> #include "hello.h" void hello(const char* name) { printf("Hello, %s!\n", name); }
Compile;
$ gcc -Wall main.c hello.c -o helloC Index
This is part of the LeetIO System Documentation. Copyright (C) 2021 LeetIO Team. See the file Gnu Free Documentation License for copying conditions.