How do you do the highlighted part in terminal for macbook? Can you please scree
ID: 3593051 • Letter: H
Question
How do you do the highlighted part in terminal for macbook? Can you please screenshot the process?
EK125 HW2--bash-80x24 dhcp-wifi-8021x-168-122-215-102: EK125 HW2 apapadak$ ls converter.c dhcp-wifi-8021x-168-122-215-102: EK125 HW2 apapadak$ gcc -o hello hello.c dhcp-wifi-8021x-168-122-215-102: EK125 HW2 apapadak$ ls converter.c dhcp-wifi-8021x-168-122-215-102:EK125 HW2 apapadak$ ./hello Hello world! Welcome to EK125, time to learn C! dhcp-wifi-8021x-168-122-215-102:EK125 HW2 apapadak$ hello. c image.c hello hello.c image. c It is also possible to pass arguments to the code from the command line. If you were working with your default a.out, and you wanted to pass a number, you could type .la.out 5 so that your .c file can do something with the user input of 5 - which will be determined by the program itself. Whatever you type after ./a.out are called command line arguments. Such an example is the image.c file, which expects a word as a command line argument. Try it out, e.g with .la.out hello What you will have to do for this part of the homework is to compile the three .c files that are given to you: hello.c, image.c, converter.c and compile these three .c files with executable filenames with the same name as the original filenames themselves. For example, compile the hello.c file to the executable named hello. Then, you are to see how they are actually run by executing the file. You already know that hello.c just prints two sentences and that image.c just takes one argument which is a string. The other program, converter.c, requires an integer as a command line argument. Save the three executable files in the same folder that contain the three .c files, as well as with screenshots of you renaming the outputs and running them, showing that you clearly understand how they work. You are to keep all these in one folder named with the format: LastNameFirstName EK125HW2Explanation / Answer
To compile the files, just use the following commands:
gcc hello.c
gcc image.c
gcc converter.c
To compile the files and use an executable with the filename :
gcc -o hello hello.c
gcc -o image image.c
gcc -o converter converter.c
To execute the files:
./hello
./image
./converter 123
To pass command line argument, just write your arguments after the name of the executable while executing it.
Hope this helped, do comment if you have any doubt regaridng this. Thumbs up if this helped!
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.