-
Int and Chars
Ok, I'm not sure exactly how to explain this but I'll try my best...
1. a function passes an unsigned in the form functionName(unsigned number)
2. I store it in an integer, i.e. int store = number; (and say number is: 1965)
3. I convert it to char-> char converted[5];
sprintf (converted, "%d", store);
My question is I want to seperate say 19 from 1965 and store it in an integer, and 65 in another integer, how do i go abouts. BTW, I'm thinking there would be a more direct way than doing all these conversions? Thanks
-
Here's a hacked together c++ example
Code:
#include <iostream>
using namespace std;
int main()
{
int a = 1965;
int b, c;
b = a % 100;
c = (a-b) / 100;
cout << c << " " << b << "\n";
}
-
Ok, thanks alot, didn't think of that :D...
anywayz, I just realised what I'm doing wouldn't work. I tried it on pen+paper but yea, it only works with 4 digits..and I can't figure it out with less..
This is my scenario, to work out the century when you input a year but I don't even noe how the centuries etc work..lol....and supposedly 2005 is 20th century on the website, so I'll stick to that for the moment.
http://mathforum.org/dr.math/faq/faq.calendar.html
Zeller's Rule:
f = k + [(13*m-1)/5] + D + [D/4] + [C/4] - 2*C.
D is the last two digits of the year
C stands for century:
I wonder if the formula works for years from 0 - 9999...
-
> I wonder if the formula works for years from 0 - 9999...
Well since there was no year 0, and that calendars changes from Julian to Gregorian at various times in various places, then answer is no.
http://www.absoluteastronomy.com/ref...ay_of_the_week