Thread: Everyone who reads this will laugh, such a daft question.

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    61

    Everyone who reads this will laugh, such a daft question.

    Okay i have a piece of code i'm having trouble with and need to google to try and find the error however i have completely forgot what its called, making Googling it quiet difficult.

    Yes its annoying simple just i got a head blank moment.

    in my code ive got
    Code:
    Simulation();
    then at the bottom outside main loop
    Code:
    simulaition()
    {
    Blah blah
    }
    what are these called lol im sure im going mad

  2. #2
    Registered User
    Join Date
    Sep 2011
    Location
    Stockholm, Sweden
    Posts
    131
    You seem to be calling Simulation from your main loop but the function definition says it's called simulaition. C is case sensitive, and the spelling is wrong in the definition.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    61
    Yeah that was solely a typo and not replicated in my code, basically im having trouble with "Syntax Error: }" galore around these what ever they are called, it has been a good couple of years since i've programmed and i have completely forgot what these are called so i can try and google to find the error.

  4. #4
    Registered User
    Join Date
    Sep 2011
    Location
    Stockholm, Sweden
    Posts
    131
    Oh you mean the name of '}'? Curly bracket, or curly brace, I think.

    Link

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    61
    sorry i'm not being clear lol

    what is it called when i put

    Simulation() <-- in my code designed to call a piece of code or "jump to a piece of code" outside of my main loop.

    That is so much clearer than waht i put orginally lol

  6. #6
    Registered User
    Join Date
    Sep 2011
    Location
    Stockholm, Sweden
    Posts
    131
    It's called "calling a function".

  7. #7
    Registered User
    Join Date
    Nov 2011
    Posts
    61
    Okay i do apologise i was sure there was a more technical term or name for it lol

    Am i doing this correct
    Code:
    #define Simulation ();
    
    main()
    {
    Simulation();
    }
    
    void Simulation(void)
    {
    /*Certain Formula*/
    }

  8. #8
    Registered User
    Join Date
    Sep 2011
    Location
    Stockholm, Sweden
    Posts
    131
    No. Drop the #define at the top, instead write

    Code:
    /* This is the function definition, you need this if the function is defined after it is used */
    void Simulation(void); 
    
    int main(void) /* note the return type of main */
    {
        Simulation();
        return 0;
    }
    
    void Simulation(void)
    {
        /* Code */
    }

  9. #9
    Registered User
    Join Date
    Nov 2011
    Posts
    61
    Thanks

    That Worked Brilliantly

    Had such a mind blank it was untrue
    James

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. You will laugh when you look at it!!
    By bilgee0629 in forum C++ Programming
    Replies: 12
    Last Post: 02-28-2011, 09:07 AM
  2. a little laugh
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 08-25-2006, 08:38 AM
  3. Please don't laugh...SIMPLE loop question!
    By the_lumin8or in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2006, 01:08 PM
  4. Its having a laugh now
    By Syme in forum C++ Programming
    Replies: 5
    Last Post: 03-16-2002, 07:41 PM
  5. Laugh if you must, but i still need help
    By iluvmyafboys in forum C++ Programming
    Replies: 3
    Last Post: 03-13-2002, 09:28 AM