2

Possible Duplicate:
Is there an interpreter for C?

I want to practice C a bit and I would like to have something that allows to write and test C code quickly. I want to have an interpreter with UI where I can write my code and execute it.

Are there any good solutions for that?

Community
  • 1
  • 1
dhblah
  • 9,751
  • 12
  • 56
  • 92

5 Answers5

2

The closest solution to what you are looking for seems to be the C shell (CSH) or C Scripting Language (CSL).

Alternatively, have an editor open where you will write your C sample, then have console window where you will execute your favourite C compiler. The idea is to have simple workflow like this:

$ gvim test.c
$ gcc test.c
$ ./a.out

Don't forget, C is not a scripting language. However, you may find JIT compiler for C, C++, and the likes discussion helpful.

Community
  • 1
  • 1
mloskot
  • 37,086
  • 11
  • 109
  • 136
  • I know, I just wanted to have something to not to compile/run each time I change the code. But what you're saying looks pretty simple. – dhblah Jul 09 '12 at 12:07
  • @gasan C is not a scripting language. Read somewhere about the implications, please. – mloskot Jul 09 '12 at 12:33
1

Though "interpreters" per se don't exist (or not practically), I'd advise on using a modern IDE. Eclipse + CDT allows you to have "on the fly compilation", just like in java. Your project is ready to run whenever you are, with reduced latency due to compilation (if you have a decent computer).

For other answers, I advise on NOT using directly gcc test.c. Use a makefile or use at least gcc -Wall -g -o myapp test.c top have additional information during compilation (useful as C has many more pitfalls than python). Please note as well that testis astandard program and that . might not be in your PATH : myapp is a better name than test ;-)

Bruce
  • 7,094
  • 1
  • 25
  • 42
0

There is Cling. Never used it, so I can't really tell you more, but it looks like what you are looking for.

You might also find other lead in this question: Is there an interpreter for C?

Community
  • 1
  • 1
Norswap
  • 11,740
  • 12
  • 47
  • 60
0

you can take a look at : http://codepad.org/

or the easy way is to create a sh script like :

vim $1 ; gcc $1 ; ./a.out

Damien Locque
  • 1,810
  • 2
  • 20
  • 42
0

You can't interpret C++ code as far as I know...

What you could do (and what I do when I quickly need to write some simple things ) is set up a simple make file and open a new file with some simple text editor like Kate that has a console plugin. Then you can write some code and type "make" to see the result of your code in the konsole / whichever shell you are using

Oofpez
  • 514
  • 1
  • 7
  • 18