Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / date calculation

Author
Message
DankGDK
14
Years of Service
User Offline
Joined: 12th Mar 2010
Location:
Posted: 13th Mar 2010 06:13
Hey guys,

I'm having trouble with computing a date from yyyymmdd to mm/dd/yyyy in dark gdk for c++. I know the calculations with mod and div (I think...), but I can't get them to work in my program. All the calculations need to be on one line. dbPrint won't work because I need more than one argument at once, and strcat/strcpy won't work because they're integers.

here are my mod/div calculations:
year = starDate/10000;
year=atoi(dbInput());
month_day = starDate%10000;
month_day=atoi(dbInput());
month = month_day/100;
day=atoi(dbInput());
day = month_day%100;

here is my coding for the date:

strcpy(buffer, "Your launch date is ");
strcat(buffer, dbStr(month));
strcat(buffer, "/");
strcat(buffer, dbStr(day));
strcat(buffer, "/");
strcat(buffer, dbStr(year));
dbPrint(buffer);

I listed the integers year, month, month_day and day in my variables at the start of the function as well as buffer as a char. when I run my program, it says my date is 0/0/0.

Thanks for the help!
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 13th Mar 2010 14:00 Edited at: 13th Mar 2010 14:03
Quote: "strcat/strcpy won't work because they're integers."


Then use sprintf



Quote: "year = starDate/10000;
year=atoi(dbInput());"


You're assigning each twice-over? It seems that atoi(dbInput()) is returning 0.

Success = Determination * Mood;

Login to post a reply

Server time is: 2024-11-20 03:32:48
Your offset time is: 2024-11-20 03:32:48