Home > Software engineering >  vscode unexpected token ( in hello world - C code
vscode unexpected token ( in hello world - C code

Time:06-24

I feel really stupid but this is the first time dealing with C for a basic CS course. I try to do everything but it keeps giving me a unexpected token when trying to run the code.

#include <stdio.h>
int main(void)
{
    puts("Hello World!");
}

even using printf and \n at the end, same result, always unexpected token, what am I missing? I've coded some complex javascript stuff before but this made me feel like a noob TT

enter image description here

CodePudding user response:

You should compile your code and then run the obtained executable. Install gcc and run

gcc -Wall -Wextra -pedantic ./hello.c -o hello

This will produce a binary file named "hello". Then you can run

./hello

and "Hello World!" will be printed to the screen.

  • Related