getAbs.h
int getAbs(int value);
const int h=10;
getAbs.cpp
#include "getAbs.h"
int getAbs(int value)
{
return (value>0) ? value : -value;
}
main.cpp
#include <stdio.h>
#include "getAbs.h"
int main()
{
int p = 10;
int l =9;
int k = 9/0;
int m = 0;
printf("The abs of %d is %d!\n", -1, getAbs(-1));
return 0;
}
makefile
GCC=g++
CFLAGS= -g -c -o2 -WallTARGET=main
OBJS=main.o getAbs.o
.SUFFIXES: .cpp .o
.cpp.o:
$(GCC) $(CFLAGS) -o $@ $<
.PHONY: all
all:$(TARGET)
$(TARGET):$(OBJS)
$(GCC) -o $(TARGET) $(OBJS)
.PHONY: clean
clean:
rm -f *.o
rm -f $(TARGET)