Like Tree1Likes
  • 1 Post By ooopa

expected primary-expression before ']'

This is a discussion on expected primary-expression before ']' within the C++ Programming forums, part of the General Programming Boards category; hello, i'm new to c++. i'm doing my first program. i get "expected primary-expression before ']'" error and i have ...

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

    expected primary-expression before ']'

    hello, i'm new to c++. i'm doing my first program.
    i get "expected primary-expression before ']'" error and i have no idea what's wrong =/

    Code:
    void printPolyMenu(double polyArr[][MAX_DEGREE+2], int capacity)
    {
    
        cout<<"Which polynomial do you wish to print? (0 - "<<capacity<<")"<<endl;
        int line;
        cin>>line;
        
        if(line>capacity || line<0)
        {
            cout<<"Polynomial does not exist."<<endl;
        }
        else
        {
            printPoly(polyArr[][MAX_DEGREE+2],line);  //here comes the error..
        }
        menuManager(polyArr,capacity);
    }
    //(printPoly is working fine.. just this line is doing trouble.)

    could someone help? thanks~

  2. #2
    language hopper dennis.cpp's Avatar
    Join Date
    Jan 2011
    Location
    Herborn, Hesse, Germany
    Posts
    197
    Is MAX_DEGREE+2 supposed to be the index of polyArr[]? Because you have two sets of "[]" there.
    Hardware: Intel® Core™ i7-3630QM CPU @ 2.40GHz × 8
    Operating system: Fedora 19 (64-Bit) / Linux 3.11.6-200.fc19 / KDE SC 4.11.2
    Compiler: gcc 4.8.2 with Netbeans IDE 7.4

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    8
    hmm it's supposed to be the number of "columns" in the array. i tried without writing it, but nothing works :/
    dennis.cpp likes this.

  4. #4
    language hopper dennis.cpp's Avatar
    Join Date
    Jan 2011
    Location
    Herborn, Hesse, Germany
    Posts
    197
    Sorry, my fault. Didn't realise it was a 2-dimensioned array.
    Hardware: Intel® Core™ i7-3630QM CPU @ 2.40GHz × 8
    Operating system: Fedora 19 (64-Bit) / Linux 3.11.6-200.fc19 / KDE SC 4.11.2
    Compiler: gcc 4.8.2 with Netbeans IDE 7.4

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,788
    At a guess, I'd say you probably meant to say:
    Code:
    printPoly(polyArr,line);
    ...kinda like when you call the menuManager function.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateWindow, primary expression expected
    By scwizzo in forum Windows Programming
    Replies: 3
    Last Post: 07-20-2008, 09:52 AM
  2. Expected primary expression
    By MarlonDean in forum C++ Programming
    Replies: 2
    Last Post: 06-20-2008, 03:43 PM
  3. expected primary expression
    By lilhawk2892 in forum C++ Programming
    Replies: 10
    Last Post: 11-22-2007, 06:50 PM
  4. Expected primary expression?
    By Beowolf in forum C++ Programming
    Replies: 17
    Last Post: 11-11-2007, 08:57 PM
  5. expected primary expression
    By mju4t in forum C Programming
    Replies: 2
    Last Post: 03-27-2007, 06:59 PM

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