0

Hi I am new to C. I'm taking an operating systems class right now and I have a project that requires me to create a set of semaphores. The command line takes in: filename ropt NS value1 value2 value3...valueNS
Where argv0 is the filename
Argv1 is the option to remove the semaphore set (it can also be nopt which means not to remove the set)
Argv2 is the number of semaphores
Argh3 and beyond are the values assigned to the semaphores in the set.
So my question

Is how to I take in a variable number of values from the command line? Let's say that NS is 5...how do I take in 5 values from the command line? I hope I make sense....thanks for any guidance....

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by apines
0

The number of values that will be in argv is exactly argc. When starting the program argc will be equal to the number of elements in argv, meaning that argv[0] through argv[argc-1] are existing cells.

0

Glad I could help :) please mark the thread as solved.

Edited by apines: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.