Question:
How to run a C program on Vim7 usign gcc?
Ardeshir81
2013-04-28 05:28:50 UTC
HI!
I wrote a hello world on vim7 and typed in : 'gcc hello.c' (I saved the "hello.c" file)
but Nothing happened.
I got the full instructio n of what i dif in here : http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/
Has anybody had any experience of Vim?
THNX!
Three answers:
jplatt39
2013-04-28 06:05:25 UTC
Okay I just told my vim to make a program on the tools menu. Of course it said no makefiles. Here is a tutorial:



http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/



To make a makefile you woul type in:



hello: hello.c

gcc -o hello hello.c



And save that as makefile or MakeFile.
inclusive_disjunction
2013-04-28 05:39:06 UTC
Your entire question is wrong.



1. You don't "run" a C program, you compile it. By the time the program is ready to to run, it is no longer in C, but in machine code. C is not an interpreted language.

2. GCC has nothing to do with Vim.

3. Vim has nothing to do with running other programs.

4. "Nothing happened" is ALWAYS wrong on a computer. There is ALWAYS some sort of feedback, be it an error message, a freeze, a blinking cursor, etc...

5. Since you got #4 wrong, I assume you were being dumb and entered "gcc hello.c" into Vim. As stated in #3, this is totally pointless and stupid. You must EXIT vim and THEN enter the command, assuming gcc is even installed on your system.
James Bond
2013-04-28 05:37:58 UTC
gcc Hello.c

Now check for a file with the name a.out

To run

./a.out


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...