Here is some sample code that grabs the command line arguments of a program:
#includeHere's a sample run:int main(int argc, char* argv[]) { char *prgName = NULL; char *iFileName = NULL; char *oFileName = NULL; prgName = argv[0]; iFileName = argv[1]; oFileName = argv[2]; printf("program name = '%s'\n", prgName); printf("input file name = '%s'\n", iFileName); printf("output file name = '%s'\n", oFileName); }
tick% assemble ThisGoesIn.asm ThisComesOut.obj program name = 'assemble' input file name = 'ThisGoesIn.asm' output file name = 'ThisComesOut.obj'
Question for the reader, what happens when you run this program without any command line arguments? How do you recommend fixing/preventing this problem?