To install C on your computer, you need a C compiler. Here are the steps to install the GNU C Compiler (GCC) on Windows, macOS, and Linux:
Windows:
- Download the GCC installer from the MinGW website: https://sourceforge.net/projects/mingw/files/latest/download
- Run the installer and follow the instructions to install GCC and related tools.
- Once the installation is complete, open a Command Prompt or PowerShell window and type
gcc -v
to verify that GCC is installed correctly.
macOS:
- Open a Terminal window and type
xcode-select --install
to install the Xcode command-line tools, which include GCC. - Once the installation is complete, type
gcc -v
to verify that GCC is installed correctly.
Linux:
- Open a Terminal window and type
sudo apt-get update
to update the package index. - Type
sudo apt-get install build-essential
to install GCC and related tools. - Once the installation is complete, type
gcc -v
to verify that GCC is installed correctly.
After installing the GCC compiler, you can write C code using a text editor, such as Visual Studio Code, and save the file with a .c
extension. To compile and run your C code, open a Terminal or Command Prompt window, navigate to the directory where the file is saved, and type gcc filename.c -o output
to compile the code and create an executable file. Then type ./output
to run the program.
Comments