Class 21: Command Line Arguments Flashcards
%myProg p1 p2 p3
Command line arguments
Any arguments from the command line will be placed in _____ memory
Read only
Int mina(int Argc, char **aargv)
Int main(int argc, char *argv[])
Two appropriate declarations if we want to pass command line arguments
What is argc
Contains the count of command line arguments
What is argv
Contains pointers to the individual arguments as character strings argv[] is an array of char*
% myProg 16 new old
Argv[0] points to “myProg\0”
Argv[1] points to “16\0’
Argv[2] points to “new\0”
Argv[3] points to “old\0”
Argv[4] is a NULL pointer
Because these things are of type char*, they are stored in ______ memory and an attempt to write to them will result in a segmentation fault
Read only memory
It is guaranteed that argc is non-negative and that argv[argc] is a ________
NULL POINTER
THe main() function is special. Every C program must define it exactly ____
ONCE
Int atoi()
Converts an ASCII string to an int (4 byte integer data type)
Double atof()
Converts ASCII string to 8 byte floating point data type
Float f = (float)atof()
If you want a 4-byte floating point data type