Thread: Generating Dates! Compiles but does not work...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    17

    Generating Dates! Compiles but does not work...

    I want the program to take in starting date and ending dates..and then its supposed to generate a list of dates in between the starting and ending date.

    for example...i put 5/1 2009 to 5/4 2009
    its going to generate:
    5/1 2009
    5/2 2009
    5/3 2009
    5/4 2009

    so far I have this. It compiles but it does not properly spit out a text file.
    i get

    1 2 3 4 5 6 7 8 9 10
    2 4 6 8 10 12 14 16 18 20
    3 6 9 12 15 18 21 24 27 30
    4 8 12 16 20 24 28 32 36 40
    5 10 15 20 25 30 35 40 45 50
    6 12 18 24 30 36 42 48 54 60
    7 14 21 28 35 42 49 56 63 70
    8 16 24 32 40 48 56 64 72 80
    9 18 27 36 45 54 63 72 81 90
    10 20 30 40 50 60 70 80 90 100

    this out of that. which is not what I want.
    The code is this.

    Code:
    #include <stdio.h>
    int main()
    {
    
    	int sday;
    	int smonth;
    	int syear;
    	int eday;
    	int emonth;
    	int eyear;
    	int myCal[12][2];
    	int y;
    	int m;
    	int d;
    	FILE *myOutput;
    	
    	/* create calender */
    	myCal[0][0] = 1; myCal[0][0] = 2; myCal[0][0] = 3; myCal[0][0] = 4;
    	myCal[0][0] = 5; myCal[0][0] = 6; myCal[0][0] = 7; myCal[0][0] = 8;
    	myCal[0][0] = 9; myCal[0][0] = 10; myCal[0][0] = 11; myCal[0][0] = 12;
    	
    	myCal[0][1] = 31; myCal[1][1] = 28; myCal[2][1] = 31; myCal[3][1] = 30;
    	myCal[4][1] = 31; myCal[5][1] = 30; myCal[6][1] = 31; myCal[7][1] = 31;
    	myCal[8][1] = 30; myCal[9][1] = 31; myCal[10][1] = 30; myCal[11][1] = 31;
    	
    	/* open external file */
    	myOutput = fopen ("multi.txt", "w");
    	
    	/* get nessesary inputs */
    	printf("Enter the starting day\n");
    	scanf("%d", &sday);
    	printf("Enter the starting month\n");
    	scanf("%d", &smonth);
    	printf("Enter the starting year\n");
    	scanf("%d", &syear);
    	printf("Enter the ending day\n");
    	scanf("%d", &eday);
    	printf("Enter the ending month\n");
    	scanf("%d", &emonth);
    	printf("Enter the ending year\n");
    	scanf("%d", &eyear);
    
    	/* test for leap year*/
    	if (syear %4 == 0)
    		{ myCal[2][1] = 29;}
    	else if (syear %4 > 0)
    		{ myCal[2][1] = 28;}
    		
    	/* check year */
    	for (y = syear; y <= eyear; y++)
    		{
    		checkyear(y);
    		if (y == eyear)
    			{
    			for (m=1; m<=emonth; m++)
    				{
    					if (m == emonth)
    						{
    							for (d = 1; d <=eday; d++)
    							{ 
    							fprintf(myOutput, " %d / %d / %d ", m, d, y);
    							}
    						}
    					else if (m /= emonth)
    						{
    							for (d=1; d<= myCal[m][1]; d++)
    							{ 
    							fprintf(myOutput, " %d / %d / %d ", m, d, y); 
    							}
    						}
    				}
    			}
    		else if (y == syear)
    			{
    				for (m = smonth; m<= 12; m++)
    					{
    						if (m == smonth)
    							{
    								for (d = sday; d<=myCal[m][1]; d++)
    									{
    									fprintf(myOutput, " %d / %d / %d " , m, d, y);
    									}
    							}
    						else if (m /= smonth)
    							{
    								for (d=1; d<=myCal[m][1]; d++)
    									{
    									fprintf(myOutput, " %d / %d / %d ", m, d, y);
    									}
    							}
    					}
    			}
    		else if (syear == eyear)
    			{
    				for (m=syear; m<=emonth; m++)
    					{
    						if (m == smonth && m == emonth)
    							{
    								for (d=sday; d<=eday; d++)
    									{
    									fprintf (myOutput, " %d / %d / %d ", m, d, y);
    									}
    							}
    						else if (m == smonth)
    							{
    								for (d = sday; d<= myCal[m][1]; d++)
    									{
    									fprintf (myOutput, " %d / %d / %d ", m, d, y);
    									}
    							}
    						else if (m == emonth)
    							{
    								for (d = 1; d<= eday; d++)
    									{
    									fprintf (myOutput, " %d / %d / %d ", m, d, y);
    									}
    							}
    						else if (m != emonth || m != smonth)
    							{
    								for (d=0; d<= myCal[m][1]; d++)
    									{
    									fprintf (myOutput, " %d / %d / %d ", m, d, y);
    									}
    							}
    					}
    			}
    		else if (syear != eyear || y != syear || y != eyear)
    			{
    				for (m=1; m<-12; m++)
    					{
    						for (d=1; d<myCal[m][1]; d++)
    							{
    							fprintf (myOutput, " %d / %d / %d ", m, d, y);
    							}
    					}
    			}
    		}
    					
    	
    return 0;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    You can't possibly get that text file -- every printf statement has slashes in it, so your text file (if it isn't empty) would have slashes in it too. Check the file name/file date.

    Also you sure do set myCal[0][0] a bunch of times.

    Also the logic in the if-else if-else if-else if bit at the end makes no sense whatsoever. You should reexamine your flowchart or pseudocode or etc.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,866
    I like the idea of using the day for your printing loops:

    Code:
       for(d = day1; d < day2; d++)   {
             printf("&#37;d/%d/%d", month, day, year);
       }
    You need to add code to tell the program when to change from say, the 5th month, to the 6th. A small array with the days in each month would be good for this.

    Also, overlap of the year - so after 12/31/year, your program knows to increment the year for anything afterward.

    This is one of those problems that "just sitting down and banging something out", will surely ruin the result for an inexperienced programmer. It turns into a Rube Goldberg, and yours did just that.

    I'd junk that, use the above to help organize your thoughts on paper, and then go keyboard it up.

  4. #4
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Why do you indent so much for the loops? It is extremely difficult to see what's happening.
    =========================================
    Everytime you segfault, you murder some part of the world

  5. #5
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    If you're gonna indent, you might as well do it right. It's refreshing to see someone not slacking doing half-assed single tab indents.
    Code:
    	myCal[0][0] = 1; myCal[0][0] = 2; myCal[0][0] = 3; myCal[0][0] = 4;
    	myCal[0][0] = 5; myCal[0][0] = 6; myCal[0][0] = 7; myCal[0][0] = 8;
    	myCal[0][0] = 9; myCal[0][0] = 10; myCal[0][0] = 11; myCal[0][0] = 12;
    What the hell does this do?
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  6. #6
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    ^How the hell is that refreshing indentation?
    =========================================
    Everytime you segfault, you murder some part of the world

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    Quote Originally Posted by JFonseka View Post
    ^How the hell is that refreshing indentation?
    You need to take in your sarcasm meter for a checkup.

  8. #8
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Quote Originally Posted by tabstop View Post
    You need to take in your sarcasm meter for a checkup.
    LOL
    =========================================
    Everytime you segfault, you murder some part of the world

  9. #9
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    I'm glad to finally be getting some use out of my wide-screen monitor.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  10. #10
    Registered User
    Join Date
    Mar 2008
    Posts
    17
    ok i rewrote the program.
    the program compiles again...KINDDA does what I want it to do. (yay for me)
    but it does not execute correctly.

    Code:
    #include <stdio.h>
    int main()
    {
    
    	int sday;
    	int smonth;
    	int syear;
    	int eday;
    	int emonth;
    	int eyear;
    	int myCal[12][2];
    	int y;
    	int m;
    	int d;
    	int bday;
    	int bmonth;
    	int byear;
    	
    	/* create calender */
    	myCal[0][0] = 1; myCal[1][0] = 2; myCal[2][0] = 3; myCal[3][0] = 4;
    	myCal[4][0] = 5; myCal[5][0] = 6; myCal[6][0] = 7; myCal[7][0] = 8;
    	myCal[8][0] = 9; myCal[9][0] = 10; myCal[10][0] = 11; myCal[11][0] = 12;
    	
    	myCal[0][1] = 31; myCal[1][1] = 28; myCal[2][1] = 31; myCal[3][1] = 30;
    	myCal[4][1] = 31; myCal[5][1] = 30; myCal[6][1] = 31; myCal[7][1] = 31;
    	myCal[8][1] = 30; myCal[9][1] = 31; myCal[10][1] = 30; myCal[11][1] = 31;
    	
    	/* open external file */
    	
    	/* get nessesary inputs */
    	printf ("Enter the starting day\n");
    	scanf ("%d", &sday);
    	printf ("Enter the starting month\n");
    	scanf ("%d", &smonth);
    	printf ("Enter the starting year\n");
    	scanf ("%d", &syear);
    	printf ("Enter the ending day\n");
    	scanf ("%d", &eday);
    	printf ("Enter the ending month\n");
    	scanf ("%d", &emonth);
    	printf ("Enter the ending year\n");
    	scanf ("%d", &eyear);
    	
    	byear = eyear - 1;
    	
    	
    	for (y = syear; y <= byear; y++)
    		{
    			if (y % 4 == 0)
    				{
    					myCal[1][1] = 29;
    					for (m = smonth; m <= 12; m++)
    						{
    							for (d = sday; d<= myCal[m][1]; d++)
    								{
    									printf ("%d/%d/%d \n", m, d, y);
    								}
    						}
    				}
    			else if (y % 4 > 0)
    				{
    					myCal[1][1] = 28;
    					for (m = smonth; m <= 12; m++)
    						{
    							for (d = sday; d<= myCal[m][1]; d++)
    								{
    									printf ("%d/%d/%d \n", m, d, y);
    								}
    						}
    				}
    		}
    	for (y == byear; y <= eyear; y++)
    		{
    			if (y%4 == 0)
    				{
    					myCal[1][1] = 29;
    					for (m = 0; m <= emonth; m++)
    						{
    							for (d = 0; d<= eday; d++);
    								{
    								printf ("%d/%d/%d \n", m, d, y);
    								}
    						}
    				}
    			else if (y%4 > 0)
    				{
    					myCal[1][1] = 28;
    					for (m = 0; m <= emonth; m++)
    						{
    							for (d = 0; d<= myCal[m][1]; d++)
    								{
    									printf ("%d/%d/%d \n", m, d, y);
    								}
    						}
    				}
    		}
    }
    THE ABOVE CODE GENERATES:


    1/1/2001
    1/2/2001
    1/3/2001
    1/4/2001
    1/5/2001
    1/6/2001
    1/7/2001
    1/8/2001
    1/9/2001
    1/10/2001
    1/11/2001
    1/12/2001
    1/13/2001
    1/14/2001
    1/15/2001
    1/16/2001
    1/17/2001
    1/18/2001
    1/19/2001
    1/20/2001
    1/21/2001
    1/22/2001
    1/23/2001
    1/24/2001
    1/25/2001
    1/26/2001
    1/27/2001
    1/28/2001
    2/1/2001
    2/2/2001
    2/3/2001
    2/4/2001
    2/5/2001
    2/6/2001
    2/7/2001
    2/8/2001
    2/9/2001
    2/10/2001
    2/11/2001
    2/12/2001
    2/13/2001
    2/14/2001
    2/15/2001
    2/16/2001
    2/17/2001
    2/18/2001
    2/19/2001
    2/20/2001
    2/21/2001
    2/22/2001
    2/23/2001
    2/24/2001
    2/25/2001
    2/26/2001
    2/27/2001
    2/28/2001
    2/29/2001
    2/30/2001
    2/31/2001
    3/1/2001
    3/2/2001
    3/3/2001
    3/4/2001
    3/5/2001
    3/6/2001
    3/7/2001
    3/8/2001
    3/9/2001
    3/10/2001
    3/11/2001
    3/12/2001
    3/13/2001
    3/14/2001
    3/15/2001
    3/16/2001
    3/17/2001
    3/18/2001
    3/19/2001
    3/20/2001
    3/21/2001
    3/22/2001
    3/23/2001
    3/24/2001
    3/25/2001
    3/26/2001
    3/27/2001
    3/28/2001
    3/29/2001
    3/30/2001
    4/1/2001
    4/2/2001
    4/3/2001
    4/4/2001
    4/5/2001
    4/6/2001
    4/7/2001
    4/8/2001
    4/9/2001
    4/10/2001
    4/11/2001
    4/12/2001
    4/13/2001
    4/14/2001
    4/15/2001
    4/16/2001
    4/17/2001
    4/18/2001
    4/19/2001
    4/20/2001
    4/21/2001
    4/22/2001
    4/23/2001
    4/24/2001
    4/25/2001
    4/26/2001
    4/27/2001
    4/28/2001
    4/29/2001
    4/30/2001
    4/31/2001
    5/1/2001
    5/2/2001
    5/3/2001
    5/4/2001
    5/5/2001
    5/6/2001
    5/7/2001
    5/8/2001
    5/9/2001
    5/10/2001
    5/11/2001
    5/12/2001
    5/13/2001
    5/14/2001
    5/15/2001
    5/16/2001
    5/17/2001
    5/18/2001
    5/19/2001
    5/20/2001
    5/21/2001
    5/22/2001
    5/23/2001
    5/24/2001
    5/25/2001
    5/26/2001
    5/27/2001
    5/28/2001
    5/29/2001
    5/30/2001
    6/1/2001
    6/2/2001
    6/3/2001
    6/4/2001
    6/5/2001
    6/6/2001
    6/7/2001
    6/8/2001
    6/9/2001
    6/10/2001
    6/11/2001
    6/12/2001
    6/13/2001
    6/14/2001
    6/15/2001
    6/16/2001
    6/17/2001
    6/18/2001
    6/19/2001
    6/20/2001
    6/21/2001
    6/22/2001
    6/23/2001
    6/24/2001
    6/25/2001
    6/26/2001
    6/27/2001
    6/28/2001
    6/29/2001
    6/30/2001
    6/31/2001
    7/1/2001
    7/2/2001
    7/3/2001
    7/4/2001
    7/5/2001
    7/6/2001
    7/7/2001
    7/8/2001
    7/9/2001
    7/10/2001
    7/11/2001
    7/12/2001
    7/13/2001
    7/14/2001
    7/15/2001
    7/16/2001
    7/17/2001
    7/18/2001
    7/19/2001
    7/20/2001
    7/21/2001
    7/22/2001
    7/23/2001
    7/24/2001
    7/25/2001
    7/26/2001
    7/27/2001
    7/28/2001
    7/29/2001
    7/30/2001
    7/31/2001
    8/1/2001
    8/2/2001
    8/3/2001
    8/4/2001
    8/5/2001
    8/6/2001
    8/7/2001
    8/8/2001
    8/9/2001
    8/10/2001
    8/11/2001
    8/12/2001
    8/13/2001
    8/14/2001
    8/15/2001
    8/16/2001
    8/17/2001
    8/18/2001
    8/19/2001
    8/20/2001
    8/21/2001
    8/22/2001
    8/23/2001
    8/24/2001
    8/25/2001
    8/26/2001
    8/27/2001
    8/28/2001
    8/29/2001
    8/30/2001
    9/1/2001
    9/2/2001
    9/3/2001
    9/4/2001
    9/5/2001
    9/6/2001
    9/7/2001
    9/8/2001
    9/9/2001
    9/10/2001
    9/11/2001
    9/12/2001
    9/13/2001
    9/14/2001
    9/15/2001
    9/16/2001
    9/17/2001
    9/18/2001
    9/19/2001
    9/20/2001
    9/21/2001
    9/22/2001
    9/23/2001
    9/24/2001
    9/25/2001
    9/26/2001
    9/27/2001
    9/28/2001
    9/29/2001
    9/30/2001
    9/31/2001
    10/1/2001
    10/2/2001
    10/3/2001
    10/4/2001
    10/5/2001
    10/6/2001
    10/7/2001
    10/8/2001
    10/9/2001
    10/10/2001
    10/11/2001
    10/12/2001
    10/13/2001
    10/14/2001
    10/15/2001
    10/16/2001
    10/17/2001
    10/18/2001
    10/19/2001
    10/20/2001
    10/21/2001
    10/22/2001
    10/23/2001
    10/24/2001
    10/25/2001
    10/26/2001
    10/27/2001
    10/28/2001
    10/29/2001
    10/30/2001
    11/1/2001
    11/2/2001
    11/3/2001
    11/4/2001
    11/5/2001
    11/6/2001
    11/7/2001
    11/8/2001
    11/9/2001
    11/10/2001
    11/11/2001
    11/12/2001
    11/13/2001
    11/14/2001
    11/15/2001
    11/16/2001
    11/17/2001
    11/18/2001
    11/19/2001
    11/20/2001
    11/21/2001
    11/22/2001
    11/23/2001
    11/24/2001
    11/25/2001
    11/26/2001
    11/27/2001
    11/28/2001
    11/29/2001
    11/30/2001
    11/31/2001
    12/1/2001
    0/0/2002
    0/1/2002
    0/2/2002
    0/3/2002
    0/4/2002
    0/5/2002
    0/6/2002
    0/7/2002
    0/8/2002
    0/9/2002
    0/10/2002
    0/11/2002
    0/12/2002
    0/13/2002
    0/14/2002
    0/15/2002
    0/16/2002
    0/17/2002
    0/18/2002
    0/19/2002
    0/20/2002
    0/21/2002
    0/22/2002
    0/23/2002
    0/24/2002
    0/25/2002
    0/26/2002
    0/27/2002
    0/28/2002
    0/29/2002
    0/30/2002
    0/31/2002
    1/0/2002
    1/1/2002
    1/2/2002
    1/3/2002
    1/4/2002
    1/5/2002
    1/6/2002
    1/7/2002
    1/8/2002
    1/9/2002
    1/10/2002
    1/11/2002
    1/12/2002
    1/13/2002
    1/14/2002
    1/15/2002
    1/16/2002
    1/17/2002
    1/18/2002
    1/19/2002
    1/20/2002
    1/21/2002
    1/22/2002
    1/23/2002
    1/24/2002
    1/25/2002
    1/26/2002
    1/27/2002
    1/28/2002


    what am I doing wrong???

  11. #11
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    January 1st, 2001 is normally written as 1/1/2001
    Notice that with dates, we start counting from 1, rather than 0.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  12. #12
    Registered User
    Join Date
    Mar 2008
    Posts
    17
    I present you...
    the most useless piece of code ever written...
    but it works...

    the program takes everything from starting dates and ending dates with different years...
    starting and ending dates within same years...
    starting and ending dates within same months....

    Code:
    #include <stdio.h>
    int main()
    {
    	/* declare ints */
    	int sday; int smonth; int syear; int eday; int emonth;
    	int eyear; int y; int m; int d;  int bmonth; int byear;
    	
    	/* declare array */
    	int myCal[13][2];
    	
    	/* create calender */
    	myCal[0][0] = 0; myCal[1][0] = 1; myCal[2][0] = 2; myCal[3][0] = 3;
    	myCal[4][0] = 4; myCal[5][0] = 5; myCal[6][0] = 6; myCal[7][0] = 7;
    	myCal[8][0] = 8; myCal[9][0] = 8; myCal[10][0] = 10; myCal[11][0] = 11;
    	myCal[12][0] = 12;
    	
    	myCal[0][1] = 0; myCal[1][1] = 31; myCal[2][1] = 28; myCal[3][1] = 31;
    	myCal[4][1] = 30; myCal[5][1] = 31; myCal[6][1] = 30; myCal[7][1] = 31;
    	myCal[8][1] = 31; myCal[9][1] = 30; myCal[10][1] = 31; myCal[11][1] = 30;
    	myCal[12][1] = 31;
    	
    	/* open external file */
    	
    	/* get nessesary inputs */
    	printf ("Enter the starting day\n");
    	scanf ("%d", &sday);
    	printf ("Enter the starting month\n");
    	scanf ("%d", &smonth);
    	printf ("Enter the starting year\n");
    	scanf ("%d", &syear);
    	printf ("Enter the ending day\n");
    	scanf ("%d", &eday);
    	printf ("Enter the ending month\n");
    	scanf ("%d", &emonth);
    	printf ("Enter the ending year\n");
    	scanf ("%d", &eyear);
    	
    	/* starting dates and ending dates are not in the same year */
    	if (eyear != syear)
    		{
    			/* crunching everything from start to a year before end year */
    			byear = eyear - 1;
    			for (y = syear; y <= byear; y++)
    				{
    					if (y%4 == 0)
    						{
    							myCal[2][1] = 29;
    							for (m = smonth; m <= 12; m++)
    								{
    									for (d = sday; d<= myCal[m][1]; d++)
    										{ 
    										printf ("%d/%d/%d \n", m, d, y); 
    										}
    								}
    						}
    					else if (y%4 > 0)
    						{
    							myCal[2][1] = 28;
    							for (m = smonth; m <= 12; m++)
    								{
    									for (d = sday; d<= myCal[m][1]; d++)
    										{ 
    										printf ("%d/%d/%d \n", m, d, y); 
    										}
    								}
    						}
    				}
    				
    			/* crunch everything on the ending year with byear = syear */
    			if (byear == syear)
    				{
    					if (y%4 == 0)
    						{
    							/* calculates every month before ending month */
    							myCal[2][1] = 29;
    							bmonth = emonth -1;
    							for (m=smonth; m<=bmonth; m++)
    								{
    									for (d = sday; d<= myCal[m][1]; d++)
    										{ 
    										printf ("%d/%d/%d \n", m, d, y); 
    										}
    								}
    							/* now calculates the final month */
    							if (emonth > 0)
    								{
    									for (d=1;d<=eday;d++)
    										{
    										printf ("%d/%d/%d \n", emonth, d, y);
    										}
    								}
    						}
    					else if (y%4 > 0)
    						{
    							/* calculates every month before ending month */
    							myCal[2][1] = 28;
    							bmonth = emonth -1;
    							for (m=smonth; m<=bmonth; m++)
    								{
    									for (d = sday; d<= myCal[m][1]; d++)
    										{ 
    										printf ("%d/%d/%d \n", m, d, y); 
    										}
    								}
    							/* now calculates the final month */
    							if (emonth > 0)
    								{
    									for (d=1;d<=eday;d++)
    										{
    										printf ("%d/%d/%d \n", emonth, d, y);
    										}
    								}
    						}
    				}
    			/* crunch everything on the ending year with byear not equal to syear */
    			else if (byear != syear)
    				{
    					if (y%4 == 0)
    						{
    							myCal[2][1] = 29;
    							bmonth = emonth -1;
    							for (m=smonth; m<=bmonth; m++)
    								{
    									for (d = sday; d<= myCal[m][1]; d++)
    										{ 
    										printf ("%d/%d/%d \n", m, d, y); 
    										}
    								}
    							/* now calculates the final month */
    							if (emonth > 0)
    								{
    									for (d=1;d<=eday;d++)
    										{
    										printf ("%d/%d/%d \n", emonth, d, y);
    										}
    								}
    						}
    					else if (y%4 > 0)
    						{
    							/* calculates every month before ending month */
    							myCal[2][1] = 28;
    							bmonth = emonth -1;
    							for (m=smonth; m<=bmonth; m++)
    								{
    									for (d = sday; d<= myCal[m][1]; d++)
    										{ 
    										printf ("%d/%d/%d \n", m, d, y); 
    										}
    								}
    							/* now calculates the final month */
    							if (emonth > 0)
    								{
    									for (d=1;d<=eday;d++)
    										{
    										printf ("%d/%d/%d \n", emonth, d, y);
    										}
    								}
    						}
    				}
    		}
    	
    	/* starting dates and ending dates ARE in the same year */
    	else if (syear = eyear)
    		{
    		if (y%4 == 0)
    			{
    				myCal[2][1]=29;
    				bmonth = emonth - 1;
    				for (m=smonth;m<=bmonth;m++)
    					{
    						for (d=sday; d<=myCal[m][1]; d++)
    							{
    							printf ("%d/%d/%d \n", m, d, syear);
    							}
    					
    					}
    				if (emonth > 0)
    					{
    						for (d=sday; d<=eday; d++)
    							{
    							printf ("%d/%d/%d \n", emonth, d, syear);
    							}
    					}
    			}
    		else if (y%4 > 0)
    			{
    				myCal[m][1]=28;
    				bmonth = emonth -1;
    				for (m=smonth;m<=bmonth;m++)
    					{
    						for (d=sday; d<=myCal[m][1]; d++)
    							{
    							printf ("%d/%d/%d \n", m, d, syear);
    							}
    					
    					}
    			}
    		}
    
    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 12-03-2005, 10:53 PM
  2. Why won't my OpenGL work?
    By Raigne in forum C++ Programming
    Replies: 7
    Last Post: 11-26-2005, 11:53 AM
  3. Developers Wanted
    By Quasicom in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 08-24-2005, 12:46 AM
  4. number of days between 2 dates.
    By explosive in forum C++ Programming
    Replies: 10
    Last Post: 02-17-2005, 07:30 AM
  5. capture card wont work with xp
    By scott27349 in forum Tech Board
    Replies: 6
    Last Post: 02-08-2005, 09:47 PM