注册 登录
编程论坛 C++教室

c++ 语言 这个code 无语法错误 为什么跟我表达的意思不一样 求大神指点

lche361 发布于 2019-06-28 15:40, 1640 次点击
#include <iostream>
using namespace std;
int runMenu()
{   
    cout << endl;
    cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
    cout << "      The amazing story generator     " << endl;
    cout << endl;
    cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
    cout << " [0] end testing the program          " << endl;
    cout << " [1] display 'about' information      " << endl;
    cout << " [2] read and store data from field   " << endl;
    cout << " [3] generate a random story line     " << endl;
    cout << " [4] save a story line to file        " << endl;
    cout << " [5] load saved story lines from file " << endl;
    cout << "which option would you like (0-5):    " << endl;
}
int main()
{   
    runMenu();
    cin >> option;
    if (option == 0)
    {
        cout << "bye" << endl;
        system("pause");
        return 0
    }
    else if ((option == 1) | (option == 'I'))
    {
        displayInfo();
    }
    return 0;
    system("pause");


}


c++ 萌新 问的问题可能比较低级 望见谅 谢谢
还有一个问题 最近老是碰到 路径不对是怎么个回事??
求解决方法 谢谢!!
2 回复
#2
rjsp2019-06-28 16:29
这个code 无语法错误
怎么可能,你用的是什么编译器?
(21) : error C2065: 'option' : undeclared identifier
(22) : error C2065: 'option' : undeclared identifier
(27) : error C2143: syntax error : missing ';' before '}'
(28) : error C2065: 'option' : undeclared identifier
(28) : error C2065: 'option' : undeclared identifier
(30) : error C3861: 'displayInfo': identifier not found
(33) : error C2146: syntax error : missing ';' before identifier ';'
(33) : error C2065: ';' : undeclared identifier
(33) : error C2146: syntax error : missing ';' before identifier 'system'
9 error(s), 0 warning(s)


#3
hello_py2019-06-28 19:25
貌似需要
1. #include <windows.h>
2. 定义变量 option
3. 貌似第一个"system("pause");        return 0"是多余的
4. 给出displayInfo的定义
5. 后一个return 0后面的分号不对,要换成半角分号(英文状态下的分号)
1