Using string
Hello there, i having a small issue reading string of 01/6/2005 MM/DD/YYYY.
how do i get it to read the rest of the dd and year due to the / ???
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;
int main ()
{
//asking user for info:
int num;
string data;
cout << "asking user input: ";
getline(cin, data);
// cout << "is: " << data;
num = atoi(data.c_str());
switch(atoi(data.c_str()))
{
case 1:
cout << "Jan" << endl;
break;
case 2:
cout << "Feb" << endl;
break;
case 3:
cout << "Mar" << endl;
break;
case 4:
cout << "Apr" << endl;
break;
case 5:
cout << "May" << endl;
break;
case 6:
cout << "Jun" << endl;
break;
case 7:
cout << "Jul" << endl;
break;
case 8:
cout << "Aug" << endl;
break;
case 9:
cout << "Sep" << endl;
break;
case 10:
cout << "Oct" << endl;
break;
case 11:
cout << "Nov" << endl;
break;
case 12:
cout << "Dec" << endl;
break;
default:
cout << "invalid input!" << endl;
}
// cout << data << endl;
return 0;
}
| |
so when i output it it said watever the month but doesn't tell me the dd and year please help?
Topic archived. No new replies allowed.