-3

My code---

#include <stdio.h>

int main(void)
{
    printf("hello, world\n");
}

and I get bash: syntax error near unexpected token `"firsttry.c"'

DisplayName
  • 11,688
gene
  • 1

1 Answers1

2

That's a C program, not a shell script. You have to compile it, which gets you an executable you can run.

On a modern Unix/Linux type system, the simplest way to do that is:

$ make firsttry

That only works if your local make(1) installation has rules built into it to make it understand that it can make the firsttry executable from firsttry.c without needing explicit rules in a Makefile.

On systems without that bit of smarts built in, you can do it the old-fashioned way:

$ cc firsttry.c -o firsttry

Either way, then you can run it:

$ ./firsttry
hello, world
Warren Young
  • 72,032