For writing any program we need a console (terminal) based text editor. I 'll be using vim editor, there are many more like nano, jed, emacs...
1. Open up the terminal and install vim by entering the following commands.
dnf -y update
dnf -y install vim-enhanced
2. Install necessary development tools (if not installed already). This includes the compiler.
dnf group install 'Development Tools'
3. Create a new C/C++ program with this vim command.
for C program
vi example.cfor C++ program
vi example.cpp
4. Press the i key or the insert key to start writing the program. After you have completed the program save and exit vim by typing :wq
example programs:
5.Compile the program with the following gcc command. this will create a object file, a.out which will will execute in the next step.
for C program
cc example.c
for C++ program
g++ example.cpp
6. Finally, execute the a.out object file which is created automatically after compiling the program
./a.out
Done!
Output of the above example program.
To open an existing file use the same command which is used to create a new file
vi example.c
for more vim commands visit this link http://www.techinfected.net/2014/07/vim-commands-cheat-sheet.html
Tweet
No comments:
Post a Comment