C++ Problem. I need assistance!

Ok, so here is my problem:
I want to the user to type the current date like, for example:
25.05.2011 (everything together, just separated with a ".").
Then I want to divide it into 3 "int" variables.
D is the Day, M is the month and Y is the year.

#include <iostream>
using namespace std;

string TOGETHER;
int D, M, Y;

int main (){
cin >> TOGETHER;

cout << "\n";
cout << D << "/" << M << "/" << A << "\n";

return 0;
}

Can someone help me, please?
closed account (Lv0f92yv)
Try checking out the atoi function. Alternatively, you could do it the poor mans way in a loop, checking each string between '/' characters to see if it matches. Though that is probably not a good way to go about it, lots of ugly code and error prone.

http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/
Topic archived. No new replies allowed.