Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
C programming is a fundamental skill for many software developers, and Windows provides a robust environment for writing, compiling, and executing C programs. This article will guide you through the steps to set up a C development environment on Windows, write a simple C program, and execute it using the Command Prompt (CMD).
Setting Up Your Environment
Install a C Compiler:
Set Environment Variables:
bin
directory to your system's PATH environment variable. This allows you to use the gcc
command from any Command Prompt window.bin
directory (e.g., C:\MinGW\bin
).Writing a Simple C Program
hello.c
:#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
Compiling and Executing the C Program
Open Command Prompt:
Win + R
, type cmd
, and press Enter to open the Command Prompt.Navigate to the Directory:
cd
command to navigate to the directory where you saved hello.c
. For example:
cd C:\Users\YourUsername\Documents
Compile the Program:
gcc
command to compile the C program. This command will generate an executable file named hello.exe
:
gcc hello.c -o hello.exe
Execute the Program:
hello.exe
Hello, World!
Troubleshooting Tips
gcc
is not recognized, ensure that the MinGW bin
directory is correctly added to your PATH environment variable.