It provides a vast repository of open source tools required for the development of software as it is open source that means you can change every line of code as per your requirement and use.Basically, Linux comes with pre-installed standard compilers and interpreters so you need not download it.
![]() Compile C Code Code As PerWrite your program in c 1.2 2. Compile and run code using gcc 2 Compile And Run C Code 2.1 1. Write your program in c 2.2 2. Compile and run using g Compile And Run C Code LinuxUnix provides a c compiler called gcc to compile and run the c code. Write your program in c You can use any text editor to write your code. Here we will use the nano text editor in the command-line user interface to write our program. ![]() ![]() Compile C Code Full Path OfOr if you saved it somewhere else provide the full path of that file while performing any operations on it. Now the file is saved into the home directory with the name hello.c. Its time to compile and run our code. Compile and run code using gcc Type the following command and press enter to compile the code gcc hello.c -o hello And then execute the following command to run code.hello Compile And Run C Code Running c code is similar to c but we will have to make few changes. First one is to use.cpp extension instead of using.c for c files and g compiler in place of gcc compiler. Write your program in c Type nano in the terminal and then press enter. For example nano cpphello.cpp Write your code inside the file which is opened in the terminal. Press ctrls to save the file and then ctrlx to exit from the editor. Again if you are using a GUI based text editor once your code is complete save it with.cpp extension in your home directory. Compile and run using g Type the following command and press enter to compile the code g cpphello.cpp -o cpphello And then use the following command to run the code.cpphello g is a c compiler that is used here to compile c code. For more details about the use of gcc and g compilers use gcc --help or g --help commands in your terminal.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |