【发布时间】:2011-02-22 19:50:18
【问题描述】:
我正在学习 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;
}
【问题讨论】:
-
重复Must declare function prototype in C? [我特别推荐AndreyT的回答]
-
标题说C,问题说C,标签有C++。为什么?
-
@GMan:吸引 C++ 的人们。
-
@Emile:为什么? C 不是 C++。只需用您使用的语言标记它,合适的人就会看到它,而不会欺骗其他人。
-
@GMan:我的评论很刻薄。我也不喜欢被骗。
标签: c