Pedantic error

This is a discussion on Pedantic error within the C Programming forums, part of the General Programming Boards category; Code: int main(void) /*Main function*/{ label(); /*Call display function which shows the function of program and name of programmer*/ Car_t ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    15

    Pedantic error

    Code:
    int main(void) /*Main function*/{
        label(); /*Call display function which shows the function of program and name of programmer*/
        Car_t fleet[FLEETSZ]; /*Declaring the fleet array */
        initializeArray(fleet); /*Calling the fleet initialization function*/
        int option = 0;
        while(option != 6) /*Displays the program menu*/
    43|error: ISO C90 forbids mixed declarations and code [-pedantic]|
    45|error: ISO C90 forbids mixed declarations and code [-pedantic]|

    Says the line 3 and 5 inside main function has some error. Dont know how to fix this. I need to use ansi c standard.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,893
    Basically, your declarations must come first at the top of the function (or other code block):
    Code:
    int main(void) /*Main function*/{
        Car_t fleet[FLEETSZ]; /*Declaring the fleet array */
        int option = 0;
        label(); /*Call display function which shows the function of program and name of programmer*/
        initializeArray(fleet); /*Calling the fleet initialization function*/
        while(option != 6) /*Displays the program menu*/
    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
    Oct 2012
    Posts
    15
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 07-24-2011, 09:38 PM
  2. Replies: 1
    Last Post: 11-15-2010, 10:14 AM
  3. gcc -Wall -pedantic
    By flexo87 in forum C Programming
    Replies: 5
    Last Post: 01-26-2009, 01:04 PM
  4. Replies: 3
    Last Post: 10-02-2007, 09:12 PM
  5. gcc Wall versus pedantic
    By Bajanine in forum C Programming
    Replies: 2
    Last Post: 04-28-2005, 10:58 AM

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