关键词 > comp20005/comp10002

comp20005 (semester 1) / comp10002 (semester 2) Running Programs in a Shell Within grok

发布时间:2023-09-12

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

comp20005 (semester 1) / comp10002 (semester 2)

Running Programs in a Shell Within grok

To execute and test your assignment within grok, follow these steps:

Zero: Create the correct data files and required output files in your grok environment, by (a) clicking the “+” button for each (b) file that you wish to create, making sure that (c) you end the file with a newline character (it will show as a blank line in the grok editor). You can either carefully type the data, or paste it from elsewhere.

Then click on Save” so that the new files become part of the workspace.

One: Iteratively construct/extend “program.c” using the built-in grok editor, in the usual way.

Two: Compile your program using the “Compile” button. Fix all syntax errors and warnings.

Three: To execute your program and test it, start the inbuilt grok shell by clicking on “Terminal” .

Four: Wait for the “bash$” prompt. Then execute your program as shown to create a file “output.txt”. You can also compile it in the shell if you wish, as shown. You will need “-lm” if you use the math library.

Five: Check whether your output is correct by using “diff”, which compares files. In this example

(comp20005 in 2021s1) there are two lines that are detected as different because of spelling mistakes. Your goal is to get no differences detected. The “<” lines in the output show what is in “output.txt”

(the first argument to “diff”), and the “>” lines show the corresponding lines of “meals0-out.txt”, the second argument.

 

Six: Stop the terminal shell by clicking the “Stop” button. You will then be able to edit your program again, to correct any problems. While editing you can also view the file “output.txt” that was created  by selecting it in the grok edit menu if you need to check it again.

Seven: Go back to Step One, and iterate until your program obtains the required output (OR until it is five minutes before the submission deadline!) Make new test data too, to cover different scenarios. If you have made a tricky test file that you would like to share, email it to [email protected],   and I’ll publish your test file and the output my solution program generates.

Note: We are not using grok for assignment submissions. Final assignment submissions must always be made via the LMS.