gpt4 book ai didi

c - 你必须在 C 中声明函数吗?

转载 作者:太空狗 更新时间:2023-10-29 15:36:58 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Must declare function prototype in 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;

}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com