| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have to write a program where the user enters a date (mm/dd/yy), and I can't figure out how to make it so the program recognizes all three pieces. Everything I've tried has only kept the mm.
|
|
#2
|
|||
|
|||
|
It's actually quite simple to do this.
Code:
#include <iostream>
using namespace std;
int main()
{
// Variable Declarations
int month, day, year;
char nil;
// Get user input
cout << "Please enter a date(mm/dd/yy): ";
cin >> month >> nil >> day >> nil >> year;
cout << endl << "It is: " << endl;
cout << month << "/" << day << "/" << year << endl;
system("PAUSE");
return 0;
}
The reason for the nil is to store that "/" as a seperate number. This program was designed to show you the output of how to get it. So you prolly just need the red text. |
|
#3
|
|||
|
|||
|
Thanks!
Wow that's really easy, thanks so much!
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > General - Help Please! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|