160 likes | 300 Views
Editing a C Program. 01/24/14. Objective. Use Linux to edit, compile and execute a C program. Login and Password. Don’t lose it Keep password a secret. Steps to Run a C program. Login into onyx Edit the program using vi or vim Compile the program with gcc
E N D
Editing a C Program 01/24/14
Objective Use Linux to edit, compile and execute a C program
Login and Password Don’t lose it Keep password a secret
Steps to Run a C program Login into onyx Edit the program using vi or vim Compile the program with gcc Execute the program with a.out Logout out of onyx
What are two modes in vi? Command Insert
vim I want to write a program whose output is: Martin Luther King said: I have a dream. I will write a C program to do that. I will use the vim editor to create the program.
To Execute a Program vim prog.c Edit the program Save with :wq gcc prog.c If there are errors, correct and recompile. a.out
Logout exit Right click on desk top Select “leave” Select “logout” button Important
vim Commands a, i -- Get into insert mode <esc> -- Get back to command mode x -- delete a character dd -- delete a line p -- paste u -- undo :wq -- write and quit :q! -- quit without saving. arrow keys -- move around
More vim Commands 3x -- Number makes command happen that many times. p - put (paste) r – replace G You should know the commands in the vimtutor, 1.1 to 4.1
More Linux Command Format command -options arguments Commands to know: ls, lpr, cp , rm, mv, mkdir, mv(to a directory), cd, cd .., rmdir man, more, cat exit
Login from Remote Site You can get mobaxterm or other ssh software if you have a PC For Macs see me.
Login from Remote Site You can get mobaxterm or other ssh software if you have a PC For Macs see me.
ET214 & ET213 Labs for Comp Sci.
Assignment See the website for assignment. Do program 1 for next Friday, 1/31/14
Next Week Hardware, software and algorithms Getting Started in C Programming