我无疑是一个矩阵是:为什么在这个代码:我为什么不能编译不声明类似于const
/*Asignacion de valores en arreglos bidimensionales*/
#include <stdio.h>
/*Prototipos de funciones*/
void imprimir_arreglo(const int a[2][3]);
/*Inicia la ejecucion del programa*/
int main()
{
int arreglo1[2][3] = { { 1, 2, 3 },
{ 4, 5, 6 } };
int arreglo2[2][3] = { 1, 2, 3, 4, 5 };
int arreglo3[2][3] = { { 1, 2 }, { 4 } };
printf("Los valores en el arreglo 1 de 2 filas y 3 columnas son:\n");
imprimir_arreglo(arreglo1);
printf("Los valores en el arreglo 2 de 2 filas y 3 columnas son:\n");
imprimir_arreglo(arreglo2);
printf("Los valores en el arreglo 3 de 2 filas y 3 columnas son:\n");
imprimir_arreglo(arreglo3);
return 0;
} /*Fin de main*/
/*Definiciones de funciones*/
void imprimir_arreglo(const int a[2][3])
{
int i; /*Contador filas*/
int j; /*Contador columnas*/
for (i = 0; i <=1; i++)
{
for (j = 0; j <= 2; j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
} /*Fin de funcion imprime_arreglo*/
我不能编译不宣而像常量的矩阵变量,并在一个向量我可以...为什么会发生这种行为?对不起,如果我的英语不好,我说西班牙语。我会非常感谢你的回答。从
void imprimir_arreglo(const int a[2][3]);
和
void imprimir_arreglo(const int a[2][3])
{
和你的代码
什么?你的意思是函数参数?我认为你可以,错误是什么? – MatheusOl 2013-02-20 16:36:38
我的编译器告诉我,我必须修改数组的类型,但这种行为只发生在矩阵,而不是在向量中,我想知道为什么? – 2013-02-20 19:24:37