You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自学C++编写的代码无法运行,请求帮忙排查错误

C++代码错误分析与修正

存在的错误

  • 误用中文全角引号:代码里所有输出字符串使用的是中文双引号“”,而C++编译器只识别英文半角引号""作为字符串的边界符号,这会直接导致编译失败。

修正后的代码

#include <iostream> 
#include <string> 

using namespace std; 

int main() { 
    // Declare a variable to store an integer
    int inputNumber;

    cout << "Enter an integer: ";

    // store integer given user input 
    cin >> inputNumber; 

    // The same with text i.e. string data 
    cout << "Enter your name: ";  
    string inputName; 
    cin >> inputName;  
    cout << inputName << " entered " << inputNumber << endl;  
    
    return 0; 
}

内容的提问来源于stack exchange,提问作者Hitesh Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 11:15:57