Thread: Pedantic error

  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
    28,413
    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*/
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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, 11:14 AM
  3. gcc -Wall -pedantic
    By flexo87 in forum C Programming
    Replies: 5
    Last Post: 01-26-2009, 02: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