error programa
Publicado por jorge (2 intervenciones) el 04/11/2014 08:55:55
buenas, el siguiente codigo me da varios errores y no encuento el por que, alguien me podria ayudar? pego el codigo y los errores
los errores son:
`cantidad' was not declared in this scope
In function `void leerlista(int, int*)':
`lista' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
At global scope:
`cantidad' was not declared in this scope
`int escribir(int, int)':
`lista' undeclared (first use this function)
At global scope:
`main' must return `int'
In function `int main(...)':
too many arguments to function `void leerlista(int, int*)'
at this point in file
invalid conversion from `int*' to `int'
too many arguments to function `int escribir(int, int)'
: at this point in file
Execution terminated
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
28
29
30
31
32
33
34
35
#include <stdio.h>
void leerlista(int cantidad,int lista[cantidad],int *buscado) {
int elemento;
printf("Teclealos: ");
for (elemento = 0; elemento < cantidad; elemento++)
{
scanf("%i",&lista[elemento]);
}
printf("Numero a buscar: ");
scanf("%i",&*buscado);
}
int escribir(int cantidad, int lista[cantidad], int buscado)
{
int elemento, cuenta;
cuenta = 0;
for (elemento = 0; elemento < cantidad; elemento++)
{
if (lista[elemento]==buscado)
{
cuenta++;
}
}
printf("Esta %i veces\n",cuenta);
}
void main()
{
int cantidad, buscado;
printf("Cantidad: ");
scanf("%i",&cantidad);
int lista[cantidad];
leerlista(cantidad,lista,&buscado);
escribir(cantidad,lista,buscado);
}
los errores son:
`cantidad' was not declared in this scope
In function `void leerlista(int, int*)':
`lista' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
At global scope:
`cantidad' was not declared in this scope
`int escribir(int, int)':
`lista' undeclared (first use this function)
At global scope:
`main' must return `int'
In function `int main(...)':
too many arguments to function `void leerlista(int, int*)'
at this point in file
invalid conversion from `int*' to `int'
too many arguments to function `int escribir(int, int)'
: at this point in file
Execution terminated
Valora esta pregunta


0