string date

what is the problem??plz finfd the error and solve this..

#include<iostream>
#include<string>

using namespace std;

int main(){
string date;
string month;
string year;

cout<<"Enter A month ";
cin>>month;

cout<<"Enter Date ";
cin>>date;

cout<<"Enter Year ";
cin>>year;

switch (month){

case 'january':
cout << "01/"; break;
case 'february':
cout << "02/"; break;
case 'march':
cout << "03/"; break;
case 'april':
cout << "04/"; break;
case 'may':
cout << "05/"; break;
case 'june':
cout << "06/"; break;
case 'july':
cout << "07/"; break;
case 'august':
cout << "08/"; break;
case 'september':
cout << "09/"; break;
case 'october':
cout << "10/"; break;
case 'november':
cout << "11/"; break;
case 'december':
cout << "12/"; break;

default:
cout << "false";



}

cout<<date<<"/";

int sz=year.size();
for(int i=sz-1;i<=sz;i++){
cout<<year[i];
}

}
Single quotes are used for characters rather than strings
Strings use double quotes
You cannot use strings in a switch statement in c++
i am doing it by also if else statement....there makes same problem
If you're doing it the correctly with if statements then no there shouldnt be any problem. The reason its not working is because you're probably doing it incorrectly. So why dont you show the same code done with if statements so we can take a look at whats wrong.

And please... I know me and many others have told you this literally over 10 times now, but just use code tags for the love of mine and everybody else's eyes. Its much clearer to spot things that are wrong and people can help you out better if you use code tags. Its that simple, use code tags. Just follow the instructions on this page and stop ignoring everytime someone mentions it - http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
Topic archived. No new replies allowed.