Thread: Weird Errors in C Compiler

  1. #1
    Registered User VEN0M's Avatar
    Join Date
    Jun 2012
    Posts
    16

    Weird Errors in C Compiler

    I am using Geany to start out programming in C. I make this simple program:

    #include <stdio.h>


    int main(int argc, char **argv)


    printf("Hello World!")

    I run "Make filename" and then run ./filename.c and I get this error:

    ./example.c: line 3: syntax error near unexpected token `('

    ./example.c: line 3: `int main(int argc, char **argv)'

    I know that this is not a spelling or syntax error because I have copied programs from websites and they still fail.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    You don't run filename.c, you run whatever the name of the generated executable is. Might be a.out, might not be. I don't know Geany.

    in any event, if you want help, copy the exact program in code tags, the exact error messages.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Is the lack of semi-colons and braces deliberate?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User keyboard's Avatar
    Join Date
    Nov 2011
    Posts
    8
    I would not copy the code from a website. Sometimes they make errors. I once posted something on my site and it was not displaying the code right because of the way HTML works. I fixed it later.
    Type things out yourself.
    Also, I would recommend not using an IDE they do some things for you which is not good all the time. Use a simple text editor like Vim or Gedit.
    If you have gcc compile like this:

    Code:
    $ gcc -o example example.c
    There is an easier way to write the hello world program. Do a search.

  5. #5
    Registered User VEN0M's Avatar
    Join Date
    Jun 2012
    Posts
    16
    wow... thanks a lot! I compiled it with gcc and it worked perfectly. I have used gedit before... but I think it is faster to use and IDE. But then again... I am a noobie. So i'll just wait and see. Thanks for your help!

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Geany is a lightweight IDE, but I use it as a programming text editor.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird errors, please help.
    By Rob4226 in forum C++ Programming
    Replies: 16
    Last Post: 04-29-2008, 01:07 AM
  2. New compiler - Weird errors -,-.
    By Blackroot in forum C++ Programming
    Replies: 8
    Last Post: 08-27-2006, 07:23 AM
  3. weird errors
    By R3N3G4D3 in forum Windows Programming
    Replies: 0
    Last Post: 06-14-2005, 06:54 AM
  4. Weird errors
    By kinghajj in forum C Programming
    Replies: 7
    Last Post: 04-29-2005, 07:49 AM
  5. Weird Compiler Errors
    By kinghajj in forum Tech Board
    Replies: 7
    Last Post: 01-22-2004, 11:45 PM