Completely confused on how to do this:

(a) Write function "daysbetween" which takes two dates and returns the number of days in between them.

(b) write the function "adddays" which takes a date and an integer, and returns a new date which is the given date, plus the given number of days.

``````#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#define STARTRANDOM srand((unsigned) time(NULL))
typedef struct {
int month, day, year;
} date;
typedef struct  {
char name[10];
int age;
float salary;
date dob;
} human_being;
date makedate(int month, int day, int year)
{
date tmpdate;
tmpdate.month = month;
tmpdate.day = day;
tmpdate.year = year;
return tmpdate;
}
void printdate(date d)
{
printf("%.2d/%.2d/%.4d", d.month,d.day,d.year);
}
date getdate()
{
int m, d, y;
printf("Enter the month: ");
scanf("%d", &m);
printf("Enter the day: ");
scanf("%d", &d);
printf("Enter the year: ");
scanf("%d", &y);
return makedate(m,d,y);
}
int sameyear(date d1, date d2)
{
return (d1.year == d2.year);
}
int samedate(date d1, date d2)
{
//  return sameyear(d1,d2) && samemonth(d1,d2) && sameday(d1,d2);
return (daysbetween(d1,d2) == 0);
}
int daysbetween(date d1, date d2)
{

}
int main(int argc, char *argv[])
{
human_being employee;
date today, yesterday, tomorrow, apptmt[100];

//  today.month = 2;
//  today.day = 6;
//  today.year = 2006;
//today = February 6, 2006;
//today = 2,6,2006;
today = makedate(2,6,2006);
yesterday = makedate(2,5,2006);
apptmt[0] = makedate(3,1,2006);
today = getdate();
printf("Today is ");
printdate(today);
putchar('\n');

system("pause");
return 0;
}``````

And...

Are we supposed to read your entire program, figure out what's missing, and add it for you?

Shouldn't you maybe tell us what you're completely lost about? What doesn't work, and where the specific area is in the code you posted?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.