12.07.2015 Views

CSCI 102

CSCI 102

CSCI 102

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Command Line Arguments‣ Recommended usage:– Upon startup check argc to make surethe user has input the desired numberof args (remember the executablecounts as one of the args.)‣ Problem:– Each argument is a textstring…for numbers we want itsnumeric representation not itsASCII representation– cstdlib defines:atoi() [ASCII to Integer] andatof() [ASCII to float/double]– Each of these functions expects apointer to the string to convertargv[0]argv[1]argv[2]argv[3]#include #include using namespace std;p r o g 1 \04 \00 . 5 \01 0 0 0 0 0 \0// char **argv is the same as char *argv[]int main(int argc, char **argv){int init, num_sims;double p;if(argc < 4){cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!