代码之家  ›  专栏  ›  技术社区  ›  samuraiseoul

CIN后程序停止

  •  -1
  • samuraiseoul  · 技术社区  · 14 年前

    嗨,我正在编写这个程序,但我无法让它甚至开始查看其他代码是否有问题。

    我有这个:

        int main()
    {
        int answer;
        int test;
        cout << "Please Enter the number to be tested: ";
        cin >> test; //Gets number to be tested
            cout << "here";
        answer = factor(test);
        cout << "The answer is:" << answer;
        return 0;
    }
    

    现在。它将打印出第一个字符,然后到达CIN,获取号码,但不会做任何事情。甚至连第二个都不打印。有什么想法吗?

    我是一个新手,也没做过太多的事情,所以欢迎你多给我一个白痴般的解释。D:谢谢。

    5 回复  |  直到 8 年前
        1
  •  3
  •   Christian    14 年前

        2
  •  1
  •   BastiBen    14 年前

    << endl; cout

    int main()
    {
    int answer;
    int test;
    cout << "Please Enter the number to be tested: ";
    cin >> test; //Gets number to be tested
        cout << "here" << endl;
    answer = factor(test);
    cout << "The answer is:" << answer << endl;
    return 0;
    }
    
        3
  •  0
  •   user513112    14 年前

    enter code here
    

    int main()
    

        4
  •  0
  •   Tony    14 年前

        5
  •  -1
  •   Malik    8 年前
    This is how it work "here " your screen doesnot be static by putting system("pause") you can do it ,on the other hand i have just made the function defination dummi still happen anything check there]
    
    
    #include<iostream>
    using namespace std;
    int factor(int x)
    {
        return x;
    }
    int main()
    {
        int answer;
        int test;
        cout << "Please Enter the number to be tested: ";
        cin >> test; //Gets number to be tested
        cout << "here";
        answer = factor(test);
        cout << "The answer is:" << answer;
    
        **system("pause");**
    
    
    }