-2

I'm trying to compile a program which draws a house using the Command Prompt in Windows 8

#include "graphics.h"
int main(void)
{
 drawRect(50,100,200,150);
 drawLine(50,100,150,25);
 drawLine(150,25,250,100);
 drawRect(130,190,40,60);
 drawRect(70,195,40,30);
 drawRect(190,195,40,30);
 drawRect(70,125,40,30);
 drawRect(190,125,40,30);
 return 0;
}

I saved it under the name house.c in the same folder as the application I'm going to use (drawapp.jar, graphics.c,graphics.h). When compiling it I used the command

gcc -o house house.c graphics.c

and it worked but when I wanted to run it using the command

./house | java -jar drawapp.jar

it showed the follwing error

'.' is not recognized as an internal or external command, operable program or batch file

The point is that this example works on Linux operating system using the terminal wondow but it doesn't work on Windows so I guess there's another command for running the program in Windows. Any ideas?

genpfault
  • 51,148
  • 11
  • 85
  • 139
KeykoYume
  • 33
  • 1
  • 3
  • 8
  • 2
    Why are you using Java for running a C compiled program ? – Claudio Oct 01 '14 at 09:41
  • 4
    try just 'house' I don't believe that you need the ./ at all. – James Snook Oct 01 '14 at 09:54
  • @Claudio: I would guess that the `graphics.c` module just outputs to `stdout` the graphic commands. Then the `drawapp` java program reads these commands and actually draws them into the screen. – rodrigo Oct 01 '14 at 11:14

1 Answers1

0

On Windows, application must be exe. Only then it will be executed. A file is opened in the application associated.

On Windows, ./house will not work. house will not work either as there is no application is associated with house. house will only work when house.exe file will be present.

doptimusprime
  • 9,115
  • 6
  • 52
  • 90
  • Not true, you do not necessarily need .exe to run a program in windows. If you compile with `gcc test.c -o test` for example, you can run your program by just typing `test` – Cantfindname Oct 01 '14 at 11:21
  • This gcc will add .exe extension to test. If there is no .exe extension to test, then it will not work in the command line. Command line runs the file with its associated application (even for .exe file if you change registry entry, it will not work.). – doptimusprime Oct 01 '14 at 11:23
  • `house will only work when house.exe file will be present.` If there is no house.exe (only house file is there), it will not work. – doptimusprime Oct 01 '14 at 11:25