![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX Desktop for Dummies Questions & Answers Questions regarding GNOME, KDE, CDE, Open Office, etc go here. All UNIX and Linux Newbies Welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "syntax error near unexpected token `fi' " | GIC1986 | SUN Solaris | 4 | 09-19-2008 09:17 AM |
| interface_file_ff.sh[99]: syntax error at line 1 : `)' unexpected | geekforu | Shell Programming and Scripting | 1 | 07-06-2008 10:54 PM |
| syntax error near unexpected token...what caused? | joshuaduan | Shell Programming and Scripting | 8 | 05-14-2007 06:02 AM |
| syntax error at line 59: `end of file' unexpected | Remi | SUN Solaris | 4 | 01-16-2007 11:48 AM |
| sh: syntax error at line 1: `>' unexpected | atiato | High Level Programming | 2 | 03-16-2004 04:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
line 3: syntax error near unexpected token `('
Hi All
I've used UNIX in the past experimenting with commands through terminal but thats about it. Im now currently teaching myself "C". Using a book from the library, the first chapter asks you run and compile your program from a command-line prompt. As you will see the program is very simple, please see below, but I am scratching my head as to why there is any problem with this when running this through UNIX. I coded the below with a textEdit and I am also using Xcode and it builds succesfully, but when I put it through UNIX I get the following ./hello.c: line 3: syntax error near unexpected token `(' ./hello.c: line 3: `int main (void)' I have searched your forums and Google and although there is much regarding the title, none covers something so simple as this one. I would very much appreciate if you could advice me what this is? Many thanks for your time and reading, Camzio Quote:
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
int main( int argc, char **argv) |
|
#3
|
|||
|
|||
|
The code should work. Have you compiled your program?
First you have compile your program with: Code:
cc hello.c -o hello Code:
./hello |
|
#4
|
|||
|
|||
|
Franklin -
Some wierd compilers expect two arguments to main. It also could be a shell error, like you think. |
|
#5
|
|||
|
|||
|
Resolved
Many thanks to all those who replied, it actually worked by using, as advised cc hello.c -o hello and then running ./hello the book says to type gcc -g -o hello hello.c. Once again thank you.
|
|||
| Google The UNIX and Linux Forums |