Thread: expected primary-expression before ']'

  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 spaghetticode's Avatar
    Join Date
    Jan 2011
    Location
    Hesse, Germany
    Posts
    259
    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 | Acer Aspire V3-771G
    OS: Debian Stretch (Testing) | Linux 4.1.0-2-amd64 | KDE Plasma 5.3.2
    Compiler: gcc 5.2.1 20150903

  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 :/

  4. #4
    language hopper spaghetticode's Avatar
    Join Date
    Jan 2011
    Location
    Hesse, Germany
    Posts
    259
    Sorry, my fault. Didn't realise it was a 2-dimensioned array.
    Hardware: Intel® Core™ i7-3630QM CPU @ 2.40GHz × 8 | Acer Aspire V3-771G
    OS: Debian Stretch (Testing) | Linux 4.1.0-2-amd64 | KDE Plasma 5.3.2
    Compiler: gcc 5.2.1 20150903

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    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