Results 1 to 5 of 5

Thread: C code not running

  1. #1
    Join Date
    Jan 2012
    Beans
    1

    C code not running

    I just copied and pasted this code, but it doesn't seem to be running.

    The code is as follows :

    #include <stdio.h>

    void main()
    (
    printf("Hello World! \n");
    }
    Attached Images Attached Images

  2. #2
    Join Date
    Oct 2009
    Location
    Reykjavík, Ísland
    Beans
    9,470
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: C code not running

    Hi, welcome to the fora.

    I have moved your post to Programming Talk.
    About problems due to upgrading
    Bringing old hardware back to life.
    Please visit Quick Links -> Unanswered Posts

  3. #3
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: C code not running

    Try this:

    Code:
    #include <stdio.h>
    
    void main()
    {
    printf("Hello World! \n");
    }
    instead of this

    Code:
    #include <stdio.h>
    
    void main()
    (
    printf("Hello World! \n");
    }
    You have a parenthesis rather than a curly brace.

  4. #4
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,297
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: C code not running

    Correct:

    Code:
    #include <stdio.h>
    
    int main(void)
    {
        printf("Hello World! \n");
        return 0;
    }
    return may be omitted in C99 only (not the default).
    「明後日の夕方には帰ってるからね。」


  5. #5
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: C code not running

    Eh, yep.

    I guess that { stuck out like a sore thumb and I wasn't even looking at anything else.

    I've been using IDEs for far too long and letting them yell at me.
    Last edited by QIII; January 27th, 2012 at 12:33 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •