Function definition into main() function.

Discussion in 'C Programming' started by CViniciusM, Feb 27, 2004.

  1. CViniciusM

    CViniciusM Guest

    Hello,

    Is the code below obey the ISO/IEC 9899:1999?

    Thanks in advance, Vinicius.

    #include <stdio.h>
    #include <stdlib.h>

    int main(void)
    {
    int a = 10;

    void print()
    {
    printf("a = %d\n\n", a);
    }

    print();

    return 0;
    }
    CViniciusM, Feb 27, 2004
    #1
    1. Advertising

  2. CViniciusM <> scribbled the following:
    > Hello,


    > Is the code below obey the ISO/IEC 9899:1999?


    No.

    > #include <stdio.h>
    > #include <stdlib.h>


    > int main(void)
    > {
    > int a = 10;
    >
    > void print()
    > {
    > printf("a = %d\n\n", a);
    > }
    >
    > print();


    > return 0;
    > }


    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "My absolute aspect is probably..."
    - Mato Valtonen
    Joona I Palaste, Feb 27, 2004
    #2
    1. Advertising

  3. CViniciusM

    Lew Pitcher Guest

    CViniciusM wrote:
    > Hello,
    >
    > Is the code below obey the ISO/IEC 9899:1999?
    >
    > Thanks in advance, Vinicius.


    No, it isn't ISO C.

    ISO C does not support the sort of "function defined within the body of
    a function" that you have coded below.

    > #include <stdio.h>
    > #include <stdlib.h>
    >
    > int main(void)
    > {
    > int a = 10;
    >
    > void print()
    > {
    > printf("a = %d\n\n", a);
    > }
    >
    > print();
    >
    > return 0;
    > }



    --
    Lew Pitcher, IT Consultant, Enterprise Application Architecture
    Enterprise Technology Solutions, TD Bank Financial Group

    (Opinions expressed here are my own, not my employer's)
    Lew Pitcher, Feb 27, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jianli Shen
    Replies:
    1
    Views:
    565
    Victor Bazarov
    Mar 13, 2005
  2. CViniciusM

    Function definition into main() function.

    CViniciusM, Feb 27, 2004, in forum: C Programming
    Replies:
    13
    Views:
    594
    Dan Pop
    Mar 3, 2004
  3. Ark
    Replies:
    1
    Views:
    404
    Chris Torek
    Aug 7, 2004
  4. Ravi
    Replies:
    17
    Views:
    906
    Kenneth Brody
    Apr 1, 2006
  5. ravi
    Replies:
    28
    Views:
    948
    Richard Heathfield
    Sep 26, 2007
Loading...

Share This Page