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. Advertisements

  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. Advertisements

  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. Advertisements

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. =?Utf-8?B?Sm9obiBCYWlsZXk=?=

    The definition of the report 'Main Report' is invalid

    =?Utf-8?B?Sm9obiBCYWlsZXk=?=, Jul 2, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    4,348
    =?Utf-8?B?Sm9obiBCYWlsZXk=?=
    Jul 2, 2005
  2. Jianli Shen
    Replies:
    1
    Views:
    864
    Victor Bazarov
    Mar 13, 2005
  3. CViniciusM

    Function definition into main() function.

    CViniciusM, Feb 27, 2004, in forum: C Programming
    Replies:
    13
    Views:
    799
    Dan Pop
    Mar 3, 2004
  4. Ark
    Replies:
    1
    Views:
    621
    Chris Torek
    Aug 7, 2004
  5. Ravi
    Replies:
    17
    Views:
    1,185
    Kenneth Brody
    Apr 1, 2006
  6. Jon Slaughter
    Replies:
    4
    Views:
    690
    Jon Slaughter
    Oct 26, 2005
  7. ravi
    Replies:
    28
    Views:
    1,329
    Richard Heathfield
    Sep 26, 2007
  8. Pierre Yves
    Replies:
    2
    Views:
    761
    Pierre Yves
    Jan 10, 2008
Loading...