Mac 下解决 Sublime Test3 编译运行C/C++ 无法使用scanf/cin

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/i_CodeBoy/article/details/86313993

前提是你的Mac上安装了sublime,具体流程自行搜索!

本文图文并茂,细节到位,亲测有效,值得一看,勿忘点赞!!!

1.按照图片和文字提示操作


{
    "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
 
    "variants":
    [
        {
            "name": "Run",
            "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && open -a Terminal.app '${file_path}/${file_base_name}'"]
        }
    ]
}

 

2.保存好以后一定要重启哦!

3.按照图片提示,选择自定义名称的BuildSystem选项

4.复制如下代码,按 Command+B ,弹出终端后输入!

#include<cstdio>
#include<iostream>
using namespace std;
int main(){

	int a,b;
	scanf("%d",&a);
	printf("%d HelloWorld!\n",a);

	cin>>b;
	cout<<b<<" HelloWorld!"<<endl;


}

猜你喜欢

转载自blog.csdn.net/i_CodeBoy/article/details/86313993