0

I was trying to compile my first C program after watching the video lecture. I'M using local vscode to compile the hello.c but getting errors. Bellow are the error messages.

After typing the command make hello it returned these:

make: cc: No such file or directory        
make: *** [<builtin>: hello] Error 127

2. After typing ```./hello.c``` it returns:

./hello.c: line 2: $'\r': command not found
./hello.c: line 3: syntax error near unexpected token `('
'/hello.c: line 3: `int main(void){'

Please need help on how to fix this. Thanks

[![Error messages received during compilation][1]][1]

.
https://i.sstatic.net/0gktK.png
2
  • Can you please edit the question and add a screenshot showing all this along with a directory listing?
    – Cliff B
    Commented Jul 31, 2023 at 22:29
  • @CliffB Thank you for your response. I have edited the post.
    – Yanda
    Commented Aug 1, 2023 at 11:22

2 Answers 2

0

No idea why you can't compile/make.

As for ./hello.c, the computer is trying to execute the source code file as a batch or script file, line by line. Since the source code isn't valid batch file code, it's throwing errors. You simply can't run a c source code file as a batch file.

Quite honestly, if you are doing CS50x, you should use the CS50 Codespace, unless you already use VSCode for C programming and know how to set it up with the correct compiler and tools you will need in the course. (Thank you, @curiouskiwi)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1

I also faced the same error using make in my local env.

Found this article online and followed the instructions, that solved the error for me.

Run the below command to install gcc (the C compiler)

$ sudo apt install gcc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .