I did a program that calculates the days different, between two dates, but I am not sure how can I add a statement that makes sure the program wont include the end date.
You can check if argv[7] is "include" using strcmp from
, and set a variable to ignore the end date if it's not
/* Rest of the code above */
if (mm2= 8)
{
if (strcmp("include", argv[7]) == 0)
{
include = 1;
}
}
day_diff = dd2 - dd1;
if (include == 0)
{
day_diff--;
}
printf("%d", day_diff);
return 0;
But i recommend you search about getopts
, a flag seems more user friendly
./daysCalculatorA -i 19 2 2019 22 4 2019