嘿家伙我是新的C++并实践我在拍“让自己的冒险游戏” 我不知道是什么问题,我相信这是与我的char变量主要是我将张贴我的main.cpp的代码如何有其他外部头文件但我看不出有任何理由发布它们也我的代码将运行,而不会给我一个错误,我不明白它如何能做到这一点,如果我的if else语句是破碎/我的字符变量。为什么代码保持跳转返回main();?
感谢您的帮助。
#include <iostream>
//LVL1
#include "C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\Dog.h"
#include "C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\Dream.h"
#include "C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\GTFO.h"
using namespace std;
int main(){
cout << "Welcome to my 'MAKE YOUR OWN ADVENTURE GAME!!!'\n";
cout << "Have Fun and enjoy the ride!\n";
cout << "Would you like to put in a cheat code??\n";
cout << "Yes or No, Cap Sensitive!\n";
char y[3];
cin >> y;
if(y == "Yes"){
cout << "Please Enter Cheat Code now\n";
char z[5];
if(z == "Dog"){
Dog();
}else if(z == "Dream"){
Dream();
}else if(z == "GTFO"){
GTFO();
}else if(z == "Path"){
Path();
}else if(z == "Sword"){
Sword();
}else if(z == "Weird"){
Weird();
}else{
cout << "Invalid Cheat Code\n";
}
}else if(y == "No"){
cout << endl;
cout << "You wake up and your house is on fire what do you do ??\n";
cout << "Quick Grab The Dog = 0, GTFO = 1, Go back to sleep = any other number\n";
int x;
cin >> x;
if(x == 0){
Dog();
}else if(x == 1){
GTFO();
}else{
Dream();
}
}else{
cout << "Invalid Answer\n\n\n";
return main();
}
return 0;
}
在旁注中。 在头犬我呼吁level2的 所有功能和我只是想知道为什么我的程序运行时有没有我我打电话 所有的level2的功能在我GTFO头和我的梦想头罚款。
PS: 只是为了除去一些混乱路径();剑();,和怪异(); 都是level2的功能。
PPS: 也只是想知道为什么我没有打电话给level2的功能在我的main.cpp做?
最后的思考: 感谢您的时间和有一个愉快的一天!
PS最后的想法: 这是一个门户网站1个引用。
你如何建议我回到主? –
不是通过调用它...使用循环! –
实际上,你应该创建一个'std :: string GetNextCommand()'函数和一个'DoNextCommand(std :: string)'函数。把这两个放在一个循环中。可能是'do {} while(stillAlive);'循环:) – MSalters