The command-line arguments are transferred to the main function through
int main (int argc, char* argv[])
The integer argc
is the no of command-line arguments, set to
one in our case, while
argv
is a vector of strings containing the command-line arguments
with argv[0]
containing the name of the program
and argv[1]
, argv[2]
, ... are the command-line args, i.e., the number of
lines of input to the program.
Here we define floating points, see also below,
through the keywords float
for single precision real numbers and
double
for double precision. The function
atof
transforms a text (argv[1]
) to a float.
The sine function is declared in math.h, a library which
is not automatically included and needs to be linked when computing
an executable file.
With the command printf
we obtain a formatted printout.
The printf
syntax is used for formatting output
in many C-inspired languages (Perl, Python, Awk, partly C++).