English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm getting an error when trying to compile this line (C), my compiler doesn't seem to be recognizing the previous declaration of "nRows, nCols":

void scalarMultiply (int nRows, int nCols, int matrix[nRows][nCols], int scalar);

Is there something wrong with it?

It's from a Stephen kochan's book, so I'm guessing it's got something to do with my compiler which is MinGW Developer Studio 2.05

2007-04-03 20:35:50 · 7 answers · asked by VIC VIC 2 in Computers & Internet Programming & Design

7 answers

Hi,
void scalarMultiply (int nRows, int nCols, int matrix[nRows][nCols], int scalar);


here, you can not give nRows, nCols as index to arrays.
you can give it as matrix[][] or int **matrix.
********
and anyhow giving parameter description in case of array is to make sure that they are of same type and order.

2007-04-03 21:17:19 · answer #1 · answered by PC 4 · 1 0

Just wrong code, I'm not sure but appears this author is not a C programmer.

int matrix[nRows][nCols]
replace it with int** matrix, for the declaration you wrote.

2007-04-03 20:58:30 · answer #2 · answered by Andy T 7 · 1 0

i comprehend in a lot of of the newer langugaqes, you're waiting to outline an array per a variable, yet i don't believe of that you'll in C++. it ought to should be a consistent, being the biggest available fee for that array length.

2016-12-03 06:19:54 · answer #3 · answered by barnhart 4 · 0 0

you can not use int matrix[inRows][nCols] rather use a pointer

2007-04-03 22:04:43 · answer #4 · answered by Anonymous · 0 0

u cant define prototype like this,strictly compiler will expect only data types, but u can define variables,but cant use them..

2007-04-03 21:36:15 · answer #5 · answered by Anonymous · 1 0

try another compiler like cygwin or Dev C

2007-04-03 21:09:03 · answer #6 · answered by JD 3 · 0 1

hi
gosfand
you cant use your argumants in your argumants

2007-04-03 20:44:11 · answer #7 · answered by DMS 1 · 1 0

fedest.com, questions and answers