Error compiling C in gcc: No such file or directory

1

I'm trying to compile a .c file but I'm not getting it. I type the following command:

gcc main.c -o HELLO

and the following error appears:

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

I did the following in the notepad itself:

include <stdio.h>

   int main()
    {
        printf("Hello World\n");
      return(0);
     }

What to do ??

    
asked by anonymous 17.09.2015 / 21:37

1 answer

5

The error says it could not find the file main.c .

To compile the file, do not just enter cmd and type

  

gcc file.c -o executable

Of the two one, either you must be in the folder that the file is in, or need to indicate the full path of the file:

Example (with the main.c file in Desktop ):

Full path :

  

gcc C: \ Users \ YourUser \ Desktop \ main.c -o HELLO

Changing directories :

  

cd C: \ Users \ YourUser \ Desktop

     

gcc main.c -o HELLO

    
17.09.2015 / 21:46