1

I have a .c file and I have only a Windows command prompt. I have to get the output of the program.

Can the program be compiled without the support of TC or TC3 environment? If so kindly help.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
soujanya
  • 29
  • 1
  • 6
  • Are you asking how to compile without a compiler? As in your [previous question](http://stackoverflow.com/questions/5005219/can-someone-please-explain-how-i-compile-my-code)? Spend some more time formulating your question so we can help you. – Jeff Kelley Feb 15 '11 at 16:18
  • Is C development SDK is installed? Without the SDK or Compiler, Linker and Libraries should be there.... You don't need any IDE to develop a simple C program. – S M Kamran Feb 15 '11 at 16:19
  • 3
    Do you have a keyboard and a monitor? – onof Feb 15 '11 at 16:21
  • 1
    The halting problem says that you can't in general get the output of a C program without (in effect) running it. There exist C interpreters, but for this job I doubt that they have any advantages over a compiler. One way or another you have to run it, so just compile it. – Steve Jessop Feb 15 '11 at 16:22
  • how to compile without a compiler?? is my question – soujanya Feb 15 '11 at 16:22
  • 2
    Is this some kind of Zen koan? How would you edit text without a text editor? How would you go snorkelling without a snorkel? If you compile the code, then whatever you use to do it would in fact be a compiler, so it is not possible to compile without a compiler. – Steve Jessop Feb 15 '11 at 16:24
  • What is the sound of a non-program running? – Edwin Buck Feb 15 '11 at 16:27
  • 2
    You can use sites such as http://codepad.org for this – Paul R Feb 15 '11 at 16:28
  • 1
    @Paul, Thanks for the tool reference. Interesting. – Edwin Buck Feb 15 '11 at 16:30
  • Valid question, IMNVHO - sometimes we need to compile and run code on platforms where a compiler is not available and/or can not be installed for some reason. Online resources are a useful solution in this kind of situation. Voting to re-open. – Paul R Feb 15 '11 at 16:32
  • @Paul: as is, the question wants to avoid "compiling the code", not "running a compiler locally". – R. Martinho Fernandes Feb 15 '11 at 16:35
  • Hey and if you arrange for a keyboard and a monitor you'd probably like to begin making your own compiler :P – Kartikya Feb 15 '11 at 17:28
  • 1
    @Paul R: ah, well, if the questioner has a *web browser* then all sorts of possibilities open up. Should have said so in the question ;-). +1 on your answer for coming up with something useful. – Steve Jessop Feb 16 '11 at 12:07
  • @Steve Jessop: well perhaps rashly I assumed that if the OP was able to post a question to SO then there was a high probability that they might have access to a web browser. ;-) – Paul R Feb 16 '11 at 14:07
  • 1
    @Paul: I dread to think what browser they're launching from a DOS prompt. IE 5, maybe? – Steve Jessop Feb 16 '11 at 15:25
  • @Steve Jessop: or maybe Lynx ? http://lynx.browser.org/ – Paul R Feb 16 '11 at 15:49
  • 1
    @Paul: if either of those can handle SO's Javascript, then they're due more credit than I thought. – Steve Jessop Feb 16 '11 at 17:20
  • @Steve: I'm almost tempted to fire up Lynx and see what happens. ;-) – Paul R Feb 16 '11 at 19:26
  • Sorry all, what the question meant was without TC or TC3 can the c program be compiled. Probably it can be done with gcc. Thank you all for the suggestions – soujanya Apr 25 '15 at 14:35
  • Is your goal to get the C program to compile and run under Windows? Or do you actually have MS-DOS (a long obsolete 16-bit operating system) installed somewhere that you could use? – Ross Ridge Apr 26 '15 at 17:34
  • @RossRidge It is to get the C program compiled and run under windows – soujanya Apr 27 '15 at 02:01

3 Answers3

3

Assuming you have internet access there are sites such as http://codepad.org which allow you to compile and run small programs in various languages online. Supported languages include C, C++ and many others.

Paul R
  • 208,748
  • 37
  • 389
  • 560
  • 1
    I'm upvoting for the reference to a nice tool, but this does not comply with the part of the question that says "without *compiling* it". ;) – R. Martinho Fernandes Feb 15 '11 at 16:34
  • @Martinho: strictly speaking you're correct, but I'm interpreting the question as meaning "without a compiler", which may or may not be correct. – Paul R Feb 15 '11 at 16:36
  • 1
    Yep, well done for coming up with an interpretation of the question that isn't daft! – Steve Jessop Feb 16 '11 at 12:08
  • 1
    Sorry all what the question meant was without TC or TC3 can the c program be compiled. Probably it can be done with gcc. Thank you all for the valuable suggestions. – soujanya Apr 25 '15 at 14:33
  • @soujanya: thank for for following up on your question > 4 years after asking it ! – Paul R Apr 25 '15 at 14:35
  • 1
    @Paul: Sorry for the delay !!! – soujanya Apr 25 '15 at 14:39
  • @soujanya: that's OK - I was just surprised to see a comment after such a long time ! You might want to consider accepting one of the answers now (click on the check mark next to the answer that you found most helpful). – Paul R Apr 25 '15 at 14:40
  • 1
    @Paul: will be regular here on ..sorry Paul I didnt find any check mark next to the answers..!! You provided a very useful tool missed it all these years..!!!!! – soujanya Apr 25 '15 at 14:47
  • OK - there might not be a check mark visible because the question has been closed. I've voted to re-open it now, but it needs 4 more votes. – Paul R Apr 25 '15 at 14:49
  • 1
    Hope it re-opens soon and thanks for your support... – soujanya Apr 25 '15 at 14:53
2

If you only have a ".c" file, then you don't have a program. You must compile the program first to make an executable, and then you must run the program to get its output.

Paul R
  • 208,748
  • 37
  • 389
  • 560
Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
  • how do i compile that particular file when no compiler is provided to me?? – soujanya Feb 15 '11 at 16:26
  • No compiler is provided to you because they want to see if you can write the code without the assistance of a compiler. Later, after you submit your solution, they will compile it as a test to see how well you really know the language. – Edwin Buck Feb 15 '11 at 16:53
  • after verifying the code the output is asked to be shown – soujanya Feb 15 '11 at 16:57
  • Then this homework is about understanding what the program is supposed to do and figuring out it's outcome. Basically they expect from you, that you run that program in your head. Note that the halting problem does not mean, that the output of no program can be statically determined. It means, that there are programs, for which a statical determination of their output is impossible. But I'm pretty sure the program given to you halts. – datenwolf Feb 15 '11 at 18:37
  • What the question meant was without TC or TC3 can the c program be compiled. Probably it can be done with gcc. Thank you all for the suggestions – soujanya Apr 25 '15 at 14:35
2

You could install Cygwin and then compile it using gcc.

Jeff Ames
  • 2,044
  • 13
  • 18