Created
December 4, 2012 13:11
-
-
Save juanfal/4203746 to your computer and use it in GitHub Desktop.
Mes de una fecha en cadenas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mesdeunafecha.cpp | |
// juanfc 2012-06-24 | |
// | |
#include <iostream> | |
using namespace std; | |
string mesdeunafecha(string fecha); | |
int main() | |
{ | |
cout << mesdeunafecha("4/diciembre/2012") << endl; | |
cout << mesdeunafecha("13/enero/2012") << endl; | |
cout << mesdeunafecha("13/Jan/2012") << endl; | |
return 0; | |
} | |
string mesdeunafecha(string fecha) | |
{ | |
int p1 = fecha.find("/"); | |
int p2 = fecha.find("/", p1+1); | |
return fecha.substr(p1+1, p2-p1-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment