Date Of Birth input problem

Hi. Im a begginer to c++ and im starting to explore it..
i know its a lot of time to learn it!!
im starting a biodata program and i got the first step.
damn im stuck to (date of birth) function. pls any one can help me out.
here is my question i want my programm to ask the user about date of birth.

here my stupid code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cout << "Biodata" << endl;
     cout << "Your First Name : ";
     getline (cin, FrstName);
     cout << "Your Midle Name : ";
     getline (cin,MidleName);
     cout << "Your Last Name : ";
     getline (cin,LastName);
     //this part to combine into FullName
     FullName.append("Your Full Name : ");
     FullName.append(FrstName);
     FullName.append(" ");
     FullName.append(MidleName);
     FullName.append(" ");
     FullName.append(LastName);
     
//Date of Birth 
     
     char DateBirth[] = "Date of Birth(mmm/dd/yyyy ";
     cin >> DateBirth;
     time_t now = time(DateBirth);
     char* dt = ctime(&);
     


So you want to extract the numbers between the slashes?

If so, you need to tokenize your string, and then extract the numbers is integers. Please look at these two functions: strtok() and strtol()

http://www.cplusplus.com/reference/clibrary/cstring/strtok/
http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/

An easier way would be, having the year, month, and day be inputted independently.
Topic archived. No new replies allowed.