It's UWAweek 42 (2nd semester, week 12)

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying the 2 articles in this topic
Showing 2 of 738 articles.
Currently 76 other people reading this forum.


 UWA week 38 (2nd semester, week 8) ↓
SVG not supported

Login to reply

👍?
helpful
11:15pm Tue 17th Sep, Allan W.

Hello, I was wondering if I could get clarification on the topic of passing optional command-line arguments. In the original project description, under the heading of "The steps to compile and execute an ml program", Step 6 is stated: "6. runml executes the compiled C11 program ml-12345, passing any optional command-line arguments (real numbers)" I believe this means the compiled program would need to accept arguments argv[1], argv[2]... and convert them to real-valued variables arg0, arg1 etc. The compiled program ml-12345 would need main(int argc, char *argv[]) to process this. This is more difficult than directly writing the values into the C file during translation (Step 4). For example, I could write a format string "double arg0 = %s;", argv[2]. In this simpler case, main() of ml-12345 does not need to accept any command line arguments. Is my understanding of this part of the project correct? Should we be following the original project description or is it acceptable to do the simpler task? Thanks in advance for the help.


SVG not supported

Login to reply

👍?
helpful
6:22am Wed 18th Sep, Joshua N.

"Allan Wu" <23*1*3*8@s*u*e*t*u*a*e*u*a*> wrote:
> Hello, I was wondering if I could get clarification on the topic of passing optional command-line arguments. > > In the original project description, under the heading of "The steps to compile and execute an ml program", Step 6 is stated: > > "6. runml executes the compiled C11 program ml-12345, passing any optional command-line arguments (real numbers)" > > I believe this means the compiled program would need to accept arguments argv[1], argv[2]... and convert them to real-valued variables arg0, arg1 etc. The compiled program ml-12345 would need main(int argc, char *argv[]) to process this
You don't need to do this. The arguments are "passed in" into the variables arg0, arg1, etc.
> This is more difficult than directly writing the values into the C file during translation (Step 4). For example, I could write a format string "double arg0 = %s;", argv[2]. In this simpler case, main() of ml-12345 does not need to accept any command line arguments.
This is what you are meant to do.
> Is my understanding of this part of the project correct? Should we be following the original project description or is it acceptable to do the simpler task? > > Thanks in advance for the help.
np

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy