Situatie
Sublime Text provides build systems to allow users to run external programs. Create a new build system for Sublime Text for setting up C++ compilation.
- Open Sublime Text editor and then go to Tools > Build System > New Build System.
- Paste the following code in the file and save it.
- Name the file as “CP.sublime-build“.
Solutie
Pasi de urmat
{ "cmd": ["g++.exe", "-std=c++17", "${file}", "-o", "${file_base_name}.exe", "&&", "${file_base_name}.exe<inputf.in>outputf.out"], "shell":true, "working_dir":"$file_path", "selector":"source.cpp" } The above block of code is used for taking input from the file “inputf.in” and prints the output to “outputf.out”.
Create three new files as shown below and make sure all of them are in the same folder.
file.cpp: The file for writing the code.
inputf.in: The file where we will be giving the input.
outputf.out: The file where the output will be displayed.
Now, perform the following steps:
- Select View > Layout > Columns : 3. This will create three columns in the workspace. Move the three files into three columns.
- Select View > Groups > Max Columns : 2.
- Select the build system we just created from Tools > Build System > CP.
Ready for executing the programs:
The compilation time can speed up by precompiling all the header files i.e., by precompiling the bits/stdc++.h header file. Perform the following steps for doing so:
- Navigate to the stdc++.h file. By default, this file is located at: “C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits”
- Open the Power shell or the command window on the current folder. For this right-click while pressing the Shift key.
- Run the below command to compile the header.
g++ -std = c++17 stdc++.h
Leave A Comment?