Run c program using command prompt in window
Introduction :C Program can be run using Command Prompt .We can use MS-DOS to run c Program. Every window OS comes with inbuilt Command Prompt. So we are going to use this command prompt to run our c program.
- Window’s Command Prompt
- Turbo C/C++ Compiler
Why we should run C Program using Command Prompt?
- We have Stored our C programs inside directories other than (C:/TC/bin) then we are unable to run c program.
- In order to run C Program we must copy C Program and paste it inside bin folder.
- This process is bit time consuming and complex.
Running C Program using Command Prompt :
- Create One Directory in D Drive (in my case my directory is “C Programs”)
- Now we must have Turbo C/C++ IDE installed in your system.( You may download it from here)
After installing Turbo C/C++ IDE we have this directory Structure
- Now Right Click on My Computer Icon and Click on Properties
- Click on Environment Variable Button.
- Make entry of bin inside Path Variable.
- Make Entry of TC>bin inside Path Variable and Click on OK.
- Now Open Command Prompt by typing cmd inside “Run” Option.
- Go to Path Where you have Saved your C Programs.
Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\Santoshi>D: D:\>cd C Programs D:\C Programs>
- Suppose we have Saved hello.c program inside “C Programs” folder. then type this command to Compile hello.c
D:\C Programs>tcc hello.c Turbo C++ Version 3.00 Copyright (c) 1992 Borland hello.c: Turbo Link Version 5.0 Copyright (c) 1992 Borland Available memory 4106832
- After typing “tcc command” we can compile C Program.
- Now its time to run C Program after Successful Compilation.Just Type Program name and Hit Enter you will get output on the console
Actually tcc.exe Command is located inside C:/TC/bin So we have make this entry inside path variable so that Command Prompt can find this command from that specified path.