可能重复:
在C语言中必须声明函数原型吗?
我正在学习C语言,在我读的书中这段代码有一个语句:void scalarMultiply(int nRows, int nCols, int matrix[nRows][nCols], int scalar);
。即使我不包括这行,程序似乎也可以运行?
int main(void)
{
void scalarMultiply(int nRows, int nCols, int matrix[nRows][nCols], int scalar);
void displayMatrix(int nRows, int nCols, int matrix[nRows][nCols]);
int sampleMatrix[3][5] = {
{ 7, 16, 55, 13, 12},
{ 12, 10, 52, 0, 7 },
{ -2, 1, 2, 4, 9 }
};
scalarMultiply(3, 5, sampleMatrix, 2);
} void scalarMultiply(int nRows, int nCols, int matrix[nRows][nCols], int scalar){
int row, column;
for (row = 0; row < nRows; ++row)
for (column = 0; column < nCols; ++column)
matrix[row][column] *= scalar;
}