I Have a script c++
but i running this script
This script error when i write code shirt "GC" or "PR"
but i write code "A" this script working
why ?
whether if / else if condition only 1 character ?
This is my script, help me. Thank's
#include<stdio.h> #include<conio.h> #include<iostream.h> main() { char code,size,merk[15]; long price=0; clrscr(); cout <<"\n \t GUCCI : GC"; cout <<"\n \t PRADA : PR \n"; cout <<"\n \t Armani : A"; cout <<"\n"; cout<<"Choose Your Shirt : ";cin>>code; cout<<"Size : ";cin>>size; if (code=='GC' || code=='gc') { strcpy(merk,"Gucci"); if (size=='S' || size =='s') price=45000; else if (size=='L' || size =='l') price=35000; else if (size=='M' || size =='m') price=45000; else price=60000; } else if (code=='PR' || code=='pr') { strcpy(merk,"PRADA"); if (size=='S' || size == 's') price=65000; else if (size=='L' || size =='l') price=75000; else if (size=='M' || size =='m') price=85000; else price=75000; } else if (code=='A' || code=='a') { strcpy(merk,"ARMANI"); if (size=='S' || size == 's') price=75000; else if (size=='L' || size =='l') price=95000; else if (size=='M' || size =='m') price=45000; else price=35000; } else { cout<<"Wrong Code"<<endl; } cout<<"------------------------"<<endl; cout<<"Merk : "<<merk<<endl; cout<<"Price : "<<price<<endl; getch(); }
sizeof(char)==1.std::stringcould be helpful.