Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you have a C program whose main function is in main.c and has other func

ID: 3921535 • Letter: S

Question

Suppose you have a C program whose main function is in main.c and has other functions in the files input.c and output.c:

a) What command(s) would you use on your system to compile and link this program?

b) How would you modify the above commands to link a library called process1 stored in the standard system library directory?

c) How would you modify the above commands to link a library called process2 stored in your home directory?

d) Some header files need to be read and have been found to be located in a header subdirectory of your home directory and also in the current working directory. How would you modify the compiler commands to account for this?

Explanation / Answer

a)

//To link 2 external files within a c program.This will only work if the files are present in current directory

# include "input.c"

#include"output.c"

//To compile the program in vi editor

In terminal type cc filename.c

If math.h is included,then use cc filename.c -lm

to insert a data press i

to save and quit press :wq where w means save and q means quit

to create a file vi filename.c

for execution ./a.out

b) use #include<proces1> //use angular brackets to look in standard system library directory

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote