c programming on vi

i am new in linux environment .I have used vi editor of Unix to get a programe compiled through "gcc ".kindly give me the options to get a program compiled & executed written in c on vi editor.

I want the command to compile a file and the command to get that compiled file executed with any example.:o

If u try this, it might work
1) Go to Command Mode By pressing ESC
2) Go to Ex Mode by pressing ":"
3) Issue the following command
:!gcc % -o <ObjFile> [-l library ] && ObjFile
or
:!gcc % [-l library ] && a.out

-o options lets u create a default object file instead of a.out. The first part of the command lets u compile C Code and the ('&&' ) the second part gets executed only when the first part exits with return status good. If so ,then 'ObjFile' will be created and the shell will execute the Object file else it will show u the errors and exit without executing the 'ObjFile'

Thanks for that Prasad. works with g++ also of course :slight_smile:

:!g++ % -o output && output