Compiler Gcc: Error; No Such File or Directory [Closed]

I am extremely new to programming and I am having problems with the basic starting program of, 'hello, world'.

I have downloaded MinGW and I believe I set it up correctly with the command promt by entering: setx PATH "%PATH%;C:\MinGW\bin"

Then I created this code following a guide while using Notepad++

#include <stdio.h>

int main(void)
{
  puts("Hello, world!");
  return 0;
}

saving it under c:/code/c/hello.c

When I try to compile it or run it under: gcc -o hello hello.c, I get this error

gcc: error: hello.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.

And I am not sure how to fix this. I have tried looking around, but I cant find any answers or I just don't understand them.

2

gcc: error: hello.c: No such file or directory gcc: fatal error: no input files compilation terminated.

Means that gcc is unable to find your hello.c source file. You should either cd to the source folder:

c:
cd c:\code\c\
gcc -o hello.exe hello.c

Or use a full path to the source in the command line:

gcc -o c:\code\c\hello.exe c:\code\c\hello.c
1
Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest