

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This assignment is for Network Programming course. Its about Command Line Arguments. It was given by Prof. Tausiq Dasgupta at Babasaheb Bhimrao Ambedkar University. It includes: Networking, Programming, Command, Argument, Function, Socket, Casting, Parameter, Integer, Accuracy
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!


**1. Command line arguments
C provides a fairly simple mechanism for retrieving command line parameters entered by the user. It passes an argv parameter to the main function in the program.
Example:
int main(int argc, char *argv[])
In this code, the main program accepts two parameters, argv and argc. The argv parameter is an array of pointers to string that contains the parameters entered when the program was invoked at the UNIX command line. The argc integer contains a count of the number of parameters.
The *char argv[] line is an array of pointers to string. In other words, each element of the array is a pointer, and each pointer points to a string (technically, to the first character of the string). Thus, argv[0] points to a string that contains the first parameter on the command line (the program's name), argv[1] points to the next parameter, and so on. The argc variable tells you how many of the pointers in the array are valid.
Type Cating refers to changing an entity of one data type into another. This is done to take advantage of certain features of type hierarchies. For instance, values from a more limited set, such as integers, can be stored in a more compact format and later converted to a different format enabling operations not previously possible, such as division with several decimal places' worth of accuracy.
Example:
main() { float a;