So I'm trying to make a coca cola machine to print out what the user has chosen to drink. Basically, I wan't to the user to input a word like "cocacola" as a string, then I convert that into a char type and use that with a if statement.
But when I run my code it doesn't work.
#include <iostream>
#include <string>
#include <sstream>
using namespace std ;
int main(){
cout << "You approach the Cola Machine..." ;
cout <<"these are the different drinks it offers." << endl << endl ;
cout <<"CocaCola\nSquirt\nSprite\nWater\nHorchata" << endl << endl ;
cout <<"Type in what you would like to drink: " ;
string choice ;
char sum[300] ;
cin >> choice ;
strncpy(sum, choice.c_str(), sizeof(sum));
sum[sizeof(sum) - 1] = 0;
if(choice == choice) {
if((sum == "CocaCola" || sum == "cocacola")){cout << "you've chosen CocaCola " ;}
}
return 0 ;
}
edit : I accidently put switch statement instead of (if).