VSCode 调试 C++ 之 cin 输入
2026/5/8 12:02:23 网站建设 项目流程

说明:含AI辅助生成内容

VSCode 调试 C++。

//《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++ 程序的时候,在 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)著 张海龙 袁国忠 译 中国工信出版社集团 人民邮电出版社

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询