1 Write a C program that prints the following line on stdout

1) Write a C++ program that prints the following line on stdout: Hello ECS40 from xxxxx. The program source file name should be hello.cpp . 2) Write a Makefile such that the command $ make compiles the program hello.cpp and produces an executable named hello . The Makefile should include a target named clean so that the command $ make clean removes the executable file hello . 3) Create a tar file called hello.tar containing the files hello.cpp and Makefile. Do not use data compression to create the tar file.

Solution

hello.cpp file:

Makefile

# the compiler: define as g++ for C++
CC = g++

# compiler flags:
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CFLAGS = -g -Wall

# the build target executable:
TARGET = hello

all: $(TARGET)

$(TARGET): $(TARGET).cpp
   $(CC) $(CFLAGS) -o $(TARGET) $(TARGET).cpp

clean:
   $(RM) $(TARGET)

1) Write a C++ program that prints the following line on stdout: Hello ECS40 from xxxxx. The program source file name should be hello.cpp . 2) Write a Makefile

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site