Help Unknown Syntax Error

Please excuse me if this is an easy fix, for I am new to Unix and C

'/problem1.c: line2: syntax error near unexpected token `
'/problem1.c: line2: `main()

and for one program it has

: command not found2: (above the syntax error)

As mentioned this is in C not C++, I have complied all four programs and nothing is brought up however when I try to execute it Unix displays what the picture above shows. I am unaware as to what this warning/error is, please help.

Thank you

It sounds like you've jammed C dode into a script file and tried to run it. C is not a script. Compiling .c files generates a new file, that is the file you run.

You cannot run the file named: problem1.c

Here is how you do it. gcc or cc is your compiler command - you should know which one to use.

cc problem1.c -o problem1
./problem1

./problem1 runs the compiled code, and is the compiled code. It will run only when you see no errors from the compiler.

This is probably homework, but I did nothing your teacher should and probably has already done for you. Please post homework in the homework forum.

1 Like

Thank you Jim, I mean that. Ive been trying to figure this out all day.

This is homework, my teacher did go over this and I do apologize for posting it here, I'm new to the site and did not see the homework forum.