I am trying to make a basic choose-your-own-adventure style game by developing a basic system by which the program takes user char input and makes a decision using if-else statements to append strings in a certain pattern. In the following program I have tried to use strcat after a set of conditions to yield different output, but my outputs keep failing miserably. Any help someone could offer would be incredible. '''
#include <iostream>
#include<cstring>
#include<string>
#include<iomanip>
#include<ios>
#include<limits>
using namespace std;
int main()
{
char str1[50]= "F*ck";
char str2[50]= "You";
char str3[50]= "Me";
char answer[50];
cout<< "Do you like rock music yes or no?";
cin>> answer;
if (answer== "no"){
cout<< strcat(str1,str2);
} else (answer== "yes");{
cout<< strcat(str1,str3);
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire