
Explicacion de los warning y notas
Publicado por Diego (150 intervenciones) el 11/05/2014 18:43:52
Buen dia, tengo un problema en que al parecer funciona, pero a la hora de compilarlo se generan varias notas y warnings:
El enunciado es el siguiente:
Realizar un programa que dado un arreglo de enteros lo muestre ordenado de menor a mayor.
No es necesario leer el arreglo desde el teclado, use arreglos de prueba.
Lo resolví con este código:
las advertencia y notas que se generan son las siguientes:
C:\Users\diego\Documents\Seminario lenguaje C\Ejercicios\práctica 3\5.c In function 'main':
lineas/columnas
8 2 [Warning] passing argument 1 of 'sumar_arreglos' from incompatible pointer type [enabled by default]
2 6 [Note] expected 'int *' but argument is of type 'int (*)[10]'
8 2 [Warning] passing argument 2 of 'sumar_arreglos' from incompatible pointer type [enabled by default]
2 6 [Note] expected 'int *' but argument is of type 'int (*)[10]'
8 2 [Warning] passing argument 3 of 'sumar_arreglos' from incompatible pointer type [enabled by default]
2 6 [Note] expected 'int *' but argument is of type 'int (*)[(sizetype)(dim)]'
No comprendo bien el porque de los warnings y notes.
Hace poco que empezé con C así que les agradezco.
El enunciado es el siguiente:
Realizar un programa que dado un arreglo de enteros lo muestre ordenado de menor a mayor.
No es necesario leer el arreglo desde el teclado, use arreglos de prueba.
Lo resolví con este código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
void sumar_arreglos(int *vec1, int *vec2, int * vec3, int dim);
void main(void){
int dim = 10, i, *a, *b, *c;
int vec1[] = {5,3,8,12,65,0,-9,3,10,-3};
int vec2[] = {-4,-6,10,9,88,97,-1,3,0,3};
int vec3[dim];
sumar_arreglos(&vec1, &vec2, &vec3, dim);
for (i = 0; i<dim ; i++){
printf(" %3d ", vec1[i]);
}
printf("\n");
for (i = 0; i<dim ; i++){
printf(" %3d ", vec2[i]);
}
printf("\n--------------------------------------------------\n");
for (i = 0; i<dim ; i++){
printf(" %3d ", vec3[i]);
}
}
void sumar_arreglos(int *vec1, int *vec2, int * vec3, int dim)
{
int i;
for (i = 0; i<dim ; i++){
*(vec3+i) = *(vec1+i) + *(vec2+i);
}
}
las advertencia y notas que se generan son las siguientes:
C:\Users\diego\Documents\Seminario lenguaje C\Ejercicios\práctica 3\5.c In function 'main':
lineas/columnas
8 2 [Warning] passing argument 1 of 'sumar_arreglos' from incompatible pointer type [enabled by default]
2 6 [Note] expected 'int *' but argument is of type 'int (*)[10]'
8 2 [Warning] passing argument 2 of 'sumar_arreglos' from incompatible pointer type [enabled by default]
2 6 [Note] expected 'int *' but argument is of type 'int (*)[10]'
8 2 [Warning] passing argument 3 of 'sumar_arreglos' from incompatible pointer type [enabled by default]
2 6 [Note] expected 'int *' but argument is of type 'int (*)[(sizetype)(dim)]'
No comprendo bien el porque de los warnings y notes.
Hace poco que empezé con C así que les agradezco.
Valora esta pregunta


0