I just need to convert this code: to c++. I know nothing about c. or perhaps
you can give me an idea how to start from scratch.
#include <iostream>
unsigned int daysformonth(unsigned int month, unsigned int year)
{
/* This function returns the number of days for the given month in the given
year */
return (30 + (((month & 9) == 8) || ((month & 9) == 1)) - (month == 2) -
(!(((year % 4) == 0) && (((year % 100) != 0) || ((year % 400) == 0))) && (month
== 2)));}
int main()
{
/* declarations */
unsigned int numdays, month, year, maxdays;
/* get input */
printf("Please give number of days:");
scanf("%u", &numdays);
//printf("Please give year:");
//scanf("%u", &year);
/* calculate result */
for(month = 1; numdays > (maxdays = daysformonth(month, year)); month = (month
== 12) ? 1 : (month + 1))
{
numdays -= maxdays;
if(month == 12) year++; }
/* output results */
switch(month)
{
case 1:
printf("You have entered : January %u\n", numdays);
break;
case 2:
printf("You have entered : Febuary %u\n", numdays);
break;
case 3:
printf("You have entered : March %u\n", numdays);
break;
case 4:
printf("You have entered : April %u\n", numdays);
break;
case 5:
printf("You have entered : May %u\n", numdays);
break;
case 6:
printf("You have entered : June %u\n", numdays);
break;
case 7:
printf("You have entered : July %u\n", numdays);
break;
case 8:
printf("You have entered : August %u\n", numdays);
break;
case 9:
printf("You have entered : September %u\n", numdays);
break;
case 10:
printf("You have entered : October %u\n", numdays);
break;
case 11:
printf("You have entered : November %u\n", numdays);
break;
case 12:
printf("You have entered : December %u\n", numdays);
break;
}
//printf("Day %u for month %u \n", numdays, month);//, year);
/* return succes */
system ("pause");
return 0;
}
Corey McKee
From: Thomas Hruska
Sent: Sunday, October 19, 2008 12:36 AM
To: [email protected]
Subject: Re: [c-prog] C to C++ converter
mckeecorey wrote:
> anyone now where to get a c to c++ converter? I have located only one
> but it requires the use of python which I know nothing about.
What exactly do you need this for? A lot of C code can be compiled with
a C++ compiler after spending a few hours with it. There are weird
differences but, assuming you don't have a lot of "clever tricks", it
should be a relatively straight-forward process.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/
[Non-text portions of this message have been removed]