VSCode 调试 C++ 之 cin 输入

说明:含AI辅助生成内容

VSCode 调试 C++。

cpp 复制代码
//《C++ primer plus》(第六版)中文版
//sqrt.cpp--using the sqrt() function
//程序清单2.4

#include<iostream>
#include<cmath>

int main()
{
    using namespace std;

    double area;
    cout<<"Enter the floor area,in square feet,of your home:";
    cin>>area;
    double side;
    side=sqrt(area);
    cout<<"That's the equivalent of a square"<<side<<"feet to the side."<<endl;
    cout<<"How fascinating!"<<endl;
    return 0;
}

在 VScode 中调试这个 C++ 程序的时候,cin需要在Terminal中输入内容,有时在 Terminal 中无法输入内容。

需要在 VScode 中进行设置:

  1. CTRL+,
  2. 搜索栏中输入run in terminal
  3. 勾选 Whether to run code in integrated Terminal 选项
  4. cin 就可以正常工作

sqrt.cpp 在 VScode 中运行的结果图片:

以上内容仅供参考,如有不对欢迎指正。

参考书目:《C++ Primer Plus》(第6版)中文版 【美】史蒂芬.普拉达(Stephen Prata)著 张海龙 袁国忠 译 中国工信出版社集团 人民邮电出版社

相关推荐
端平入洛21 小时前
auto有时不auto
c++
埃博拉酱1 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传
windows·ssh·visual studio code
唐宋元明清21882 天前
.NET 本地Db数据库-技术方案选型
windows·c#
加号32 天前
windows系统下mysql多源数据库同步部署
数据库·windows·mysql
哇哈哈20212 天前
信号量和信号
linux·c++
多恩Stone2 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
tryCbest2 天前
Windows环境下配置pip镜像源
windows·pip
呉師傅2 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
百事牛科技2 天前
保护文档安全:PDF限制功能详解与实操
windows·pdf
蜡笔小马2 天前
21.Boost.Geometry disjoint、distance、envelope、equals、expand和for_each算法接口详解
c++·算法·boost