help newbie compile program!

This is a discussion on help newbie compile program! within the C Programming forums, part of the General Programming Boards category; hello. i am trying to compile this c program but am encountering errors... not familiar with c logic enough to ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    help newbie compile program!

    hello. i am trying to compile this c program but am encountering errors... not familiar with c logic enough to fix it. can you try to compile and fix, or recognize error? thanks
    (this code is supposed to start process, and execute, please don't alter logic. help me fix syntax!)
    PS: i've been getting lots of error msgs but after fixing them I still am left with:

    line 1: Parse Error, expecting `SEP'
    '{ int fork(), value'

    Can anyone help? thanks!

    *begin code*

    {
    int fork(), value;

    value = fork();
    value = fork();
    printf("in main: value * %d\n", value);

    return 0;

    }

    //
    int fork(void);
    int main()
    {
    if (fork() == 0); /*child process*/
    {
    printf("hello there \n");
    return;
    }
    else /*parent process*/
    printf("good bye\n");
    printf("how are you doing?\n")
    return 0;

    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,632
    Please post your code in [code][/code] bbcode tags. Especially since you are looking for help on correcting syntax errors, post complete code that you think is syntactically correct (i.e., do not comment out parts with things like "*begin code*").
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    4
    ok sorry.

    i remember that in the future. in the meanwhile; i don't suppose you could help me with my syntax error?


  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    4
    Code:
    {
    int fork(), value;
    
    value = fork();
    value = fork();
    printf("in main: value * %d\n", value);
    
    return 0;
    
    }
    
    int fork(void);
    int main()
    {
    if (fork() == 0); /*child process*/
    {
    printf("hello there \n");
    return;
    }
    else /*parent process*/
    printf("good bye\n");
    printf("how are you doing?\n")
    return 0;
    
    }

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,632
    You can edit your original post

    Anyway, at a glance you are missing a terminating semi-colon on this line:
    Code:
    printf("how are you doing?\n")
    EDIT:
    Ah, you need to indent your code as well.

    However, why do you have a block of code in the middle of nowhere (i.e., outside of a function)?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Dec 2008
    Posts
    4
    ok - i put the semicolon i am still getting the syntax error
    Code:
    line 1: Parse Error, expecting `SEP'
    '{ int fork(), value'
    also; i am trying to show a child process and parent process.. this is going to eventually be a bigger program but i need to get these initial processes working first lol any help getting this executable will be swell!

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,632
    Well, why do you have this block of code?
    Code:
    {
        int fork(), value;
    
        value = fork();
        value = fork();
        printf("in main: value * %d\n", value);
    
        return 0;
    }
    It looks like it should be in a function.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    58
    And what is the point of assigning value twice?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inheritance and program structure planning please help a newbie
    By ninjacookies in forum C++ Programming
    Replies: 1
    Last Post: 10-23-2005, 12:18 PM
  2. newbie: steps to create and compile c program in SUSE
    By gemini_shooter in forum Linux Programming
    Replies: 12
    Last Post: 06-22-2005, 06:35 PM
  3. compile program?
    By Goosie in forum C++ Programming
    Replies: 9
    Last Post: 06-22-2005, 02:26 PM
  4. newbie needs help with C++ program
    By cyba in forum C++ Programming
    Replies: 9
    Last Post: 06-25-2004, 02:41 AM
  5. How To Embed Data In Program While Compile?
    By ooosawaddee3 in forum C++ Programming
    Replies: 1
    Last Post: 09-09-2002, 10:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21