Monday, August 22, 2005

Example: Command line arguments in C

int main(int argc, char* argv[])
{
char filename[128], base[128], end[8];
int numImages, imageNum;
int xCorners = 0;
int yCorners = 0;
int iImg;
int width;
int height;
if (argc == 6) {
sprintf(base, "%s", argv[1]);
sprintf(end, "%s", argv[2]);
numImages = atoi(argv[3]);
xCorners = atoi(argv[4]);
yCorners = atoi(argv[5]);
} else {
sprintf(base, "good\\image0");
sprintf(end, ".bmp");
numImages = 12;
xCorners = 7;
yCorners = 7;
}

No comments:

Post a Comment