[go: up one dir, main page]

0% found this document useful (0 votes)
55 views1 page

Unistd H

The document provides an overview of the unistd.h library found in Unix and Linux systems, focusing on methods related to files and processes. It specifically details the getopt function, which analyzes command line options and returns various values based on the parsing results. Additionally, it outlines key variables associated with getopt, including optarg, optopt, and optind.

Uploaded by

babbba48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Unistd H

The document provides an overview of the unistd.h library found in Unix and Linux systems, focusing on methods related to files and processes. It specifically details the getopt function, which analyzes command line options and returns various values based on the parsing results. Additionally, it outlines key variables associated with getopt, including optarg, optopt, and optind.

Uploaded by

babbba48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

unistd.h : >>>is a library found in Unix and Linux systems.

it has methods that deals with os most fucused on ( files and processes)

methods:

##>> getopt(int argc,char * argv, optstring):


used to analyse the command line options

example
getopt(argc, argv, "f:v");

the third parameter is where you put the options for your program.

: means there is a value if (there isn't you write it alone like v)

it returns int:
-1 when all options parsed
? unknown option(ivalid character)
: missing required argument(if :used)
options char valid option was found

example
int opt
while ((opt = getopt(argc, argv,"fa")
{
switch(opt)
{

case "a":
case "f":

}
}

variables in getopt:

optarg = pointer to the current option's argument(if any)

optopt = the last known option character that caused an error

optind = index of the next argv[] to be processed

You might also like