- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
4 Posted Topics
Re: These examples are overly complicated. I found a simple one that totally handles leap years. from: [URL="http://www.zedwood.com/article/102/cpp-checkdate-function-for-date-validation"]c++ checkdate date validation[/URL] [code=c] bool checkdate(int m, int d, int y) { //gregorian dates started in 1582 if (! (1582<= y ) )//comment these 2 lines out if it bothers you return false; … | |
Re: [code=c++] #include <iostream> #include <vector> #include <string> using namespace std; vector<string> explode( const string &delimiter, const string &explodeme); int main(int argc, char *argv[]) { string str = "I have a lovely bunch of cocoa nuts"; cout<<str<<endl; vector<string> v = explode(" ", str); for(int i=0; i<v.size(); i++) cout <<i << " … | |
Re: just write your own itoa. [code=c++] #include <iostream> #include <string> using namespace std; string itoa(const int &integer,int base=10) { if (integer==0) return string("0"); string a; int start, digits, piece; //count digits digits=0; piece=((integer<0)? 0-integer : integer); while( piece > 0 ) { piece-= (piece%base); piece/=base; digits++; } start=((integer<0)? 1 : … | |
Re: C works in MFC right? (sprintf/sscanf) [code=c] int main(int argc, char*argv[]) { int m,d,y; sscanf("%d/%d/%d", &m, &d, &y); if (checkdate(m,d,y)) { printf("valid\n"); } else { printf("invalid\n"); } } bool checkdate(int m, int d, int y) { //gregorian dates started in 1582 if (! (1582<= y ) )//comment these 2 lines … |
The End.