実験実習のやつ

Makefile

.PHONY: all
all: mile2kilo1 mile2kilo2 print_stars1 print_stars2

mile2kilo1: mile2kilo.o ex_mile2kilo_main.o
        gcc -o $@ $^

mile2kilo2: mile2kilo.o mile2kilo_main.o
        gcc -o $@ $^

print_stars1: print_stars.o print_stars_main1.o
        gcc -o $@ $^

print_stars2: print_stars.o print_stars_main2.o
        gcc -o $@ $^

mile2kilo_main.c

#include <stdio.h>

double my_mile2kilo(const double d_mile);

int main(void)
{
  double  d_mile;
  double  d_kilo;

  d_mile = 12.3;
  d_kilo = my_mile2kilo(d_mile);
  printf("%lf [mile] は %lf [km] です.\n", d_mile, d_kilo);

  return 0;
}

mile2kilo.c

double my_mile2kilo(const double d_mile)
{
        double d_kilo;
        
        d_kilo = d_mile * 1.619;

        return d_kilo;
}

print_stars.c

#include <stdio.h>

void my_print_stars(const int i_num)
{
        int i;

        for(i = 0; i < i_num; i++){
                printf("*");
        }

        printf("\n");
}