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
    spaghetticode
    Guest
    Is MAX_DEGREE+2 supposed to be the index of polyArr[]? Because you have two sets of "[]" there.

  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
    spaghetticode
    Guest
    Sorry, my fault. Didn't realise it was a 2-dimensioned array.

  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, 07:50 PM
  4. Expected primary expression?
    By Beowolf in forum C++ Programming
    Replies: 17
    Last Post: 11-11-2007, 09:57 PM
  5. expected primary expression
    By mju4t in forum C Programming
    Replies: 2
    Last Post: 03-27-2007, 06:59 PM