第1回勉強会の回答案
こんなのでどうだろうか。
main.c
#include <stdio.h> int main(void) { hello(); return 0; }
hello.c
#include <stdio.h> #define BUFFER_SIZE 200 void hello() { char buffer[BUFFER_SIZE]; FILE *fin; fin = fopen("message.txt", "r"); if (!fin){ printf(" not open\n "); return; } while( fgets(buffer, BUFFER_SIZE, fin) ){ printf("%s", buffer); } fclose(fin); }
gcc -c main.c gcc -c hello.c gcc main.o hello.o -o say-hello