| | |
Compiler error
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
This code is giving me the error "expected primary-expression before ']' token." After googling and looking around Daniweb I still cannot find what this means. Can anyone enlighten me?
C++ Syntax (Toggle Plain Text)
int board[*width][*height]; if(OpenBoard(boardName, width, height, board[][*height])) { } //... //function definition... bool OpenBoard(std::string *boardFileName, int *width, int *height, int board[][100])
Arrays need to be declared with constants, not variables.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Well i dont think arrays can be initialised with variables.
i think vectors are the suitable task for the job.
i think vectors are the suitable task for the job.
You can't declare arrays using sizes available at run-time.
Given that your function definition has a constant, how about
But since this is C++, how about
Given that your function definition has a constant, how about
C++ Syntax (Toggle Plain Text)
int board[100][100]; if(OpenBoard(boardName, width, height, board)) { } //... //function definition... bool OpenBoard(std::string *boardFileName, int *width, int *height, int board[][100])
But since this is C++, how about
std::vector< std::vector<int> > board; ![]() |
Similar Threads
- visual c++ strange compile error... (C++)
- Borland compiler error (C++)
- Compiler error ?? (C++)
- Compiler error with Dev-C++ (C++)
- internal compiler error (C++)
- HELP- internal compiler error? (C++)
- Compiler error (C++)
- MS Visual++ 6.0 - Error C2146, C2501 ... (C++)
Other Threads in the C++ Forum
- Previous Thread: Problems passing multidimensional arrays
- Next Thread: Character Processing and use of Functions
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion convert count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






