Parent directory Makefile main.c sum.c
Download
CC=gcc CFLAGS=-g -Wall -O0 -fno-omit-frame-pointer -fno-stack-protector LDFLAGS=-static main: main.o sum.o main.o sum.o: .PHONY: clean clean: rm -f *.o main .PHONY: all all: clean main
#include <stdio.h> long sum_array(long *p, int n); int main() { long a[5] = {0, 1, 2, 3, 4}; long sum = sum_array(a, 5); printf("sum=%ld\n", sum); }
long sum(long a, long b) { return a + b; } long sum_array(long *p, int n) { long s = 0; for (int i = 0; i < n; i++) { s = sum(s, p[i]); } return s; }