how do i? re: argc - argv
hello all,
im trying to debug a program using Labwindows/CVI (V5.5) IDE running in a dosbox (windows xp).
However as the program requires command line parameters i cant see a way to debug the program because CVI doesnt brake on breakpoints when running standalone executable, and when running the program in debug mode one cant fill the argv members, so i thought what about hardcoding the char arrays in global space then passing the arrays to the argv members, but after trying a few different ways i cant get past the compiler.
can it be done? im not an expert, been programming for a few months now.
i have been reading around this sight and have learned what argc - argv mean but dont know enough about 'c' to work out a way to do this.
my program (well most of it belongs to Ray Gardner - Public Domain) is here:
Code:
//#include <ansi_c.h>
#include "scaldate.h"
#if ISO_CAL /* MONDAY == 0 */
#define ADJ 5
#else /* SUNDAY == 0 */
#define ADJ 6
#endif
unsigned DOW(unsigned y, unsigned m, unsigned d)
{
if (m < 3)
{
m += 13;
y--;
}
else m++;
return (d + 26 * m / 10 + y + y / 4 - y / 100 + y / 400 + ADJ) % 7;
}
#include <stdio.h>
#include <stdlib.h>
/* argc is the number of command line parameters including the name of the
program , argv[] is an array of pointers to the command line parameters */
int main(int argc, char *argv[])
{
int ch;
int Day;
void usage(void);
unsigned d, m, y, days[] = {31, 29, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
char *day[2][7] = {{ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"},
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}};
char *month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",};
if (4 > argc)
usage();
y = atoi(argv[1]);
m = atoi(argv[2]);
d = atoi(argv[3]);
if (!m || m > 12)
usage();
if (!d || d > days[m - 1])
usage();
if (y < 100)
y += 1900;
Day = DOW(y, m, d);
printf("DOW(ISO_CAL=%d) returned %d, so %d %s %d is a %s\n",
ISO_CAL, Day, d, month[m - 1], y, day[ADJ - 5][Day]);
printf ("Press [Enter] to continue");
while ((ch = getchar()) != '\n' && ch != EOF);
return(0);
}
void usage(void)
{
int ch;
puts("Usage: DOW yy[yy] mm dd");
printf ("Press [Enter] to continue");
while ((ch = getchar()) != '\n' && ch != EOF);
exit(-1);
}
luigi