Foros del Web » Programación para mayores de 30 ;) » C/C++ »

No encuentro la solución a los errores

Estas en el tema de No encuentro la solución a los errores en el foro de C/C++ en Foros del Web. Hola, llevo un montón de horas intentando solucionar los errores de este código y no lo con consigo. ¿Me podéis ayudar? Saludos. Código: #include <stdio.h> ...
  #1 (permalink)  
Antiguo 01/12/2010, 14:13
 
Fecha de Ingreso: octubre-2006
Mensajes: 169
Antigüedad: 18 años, 1 mes
Puntos: 2
No encuentro la solución a los errores

Hola,

llevo un montón de horas intentando solucionar los errores de este código y no lo con
consigo.
¿Me podéis ayudar?

Saludos.



Código:
#include <stdio.h>
#include <stdlib.h>

/*Declaració de constants*/
#define MAX_DRIVERS 50
#define MAX_RACES 50

/*Declaració de tipus*/
typedef enum {FALSE, TRUE} bool;

typedef struct{
	int idRace;
	float timeRace;
	float kmRace;
} tRaceInfo;

typedef struct{
	int idDriver;
	tRaceInfo dataDriver[MAX_RACES];
	int numRaces;
} tDriver;

typedef struct{
	tDriver drivers[MAX_DRIVERS];
	int numDrivers;
} tChampionship;

/* Predeclaració de funcions*/
void obtainReadingSequence(tRaceInfo *reading, bool *endSeq, int *idDriver);
void processReadingSequence(tChampionship *championship, int idDriver, tRaceInfo reading);
void findDriver(int idDrive, tChampionship *championship, int *index);
void findRace(tRaceInfo reading, tDriver *driver, int *pos);
void insertDriver(int idDriver, int index, tChampionship *championship);
void insertRace(tRaceInfo reading, int position, tDriver *driver);
void writeResult(tChampionship championship);

int main()
{
	tChampionship championship;
	bool endSeq;
	tRaceInfo reading;
	int idDriver;

	championship.numDrivers=0;
	endSeq = FALSE;
	obtainReadingSequence(&reading, &endSeq, &idDriver);
	while(!endSeq)
	{
		processReadingSequence(&championship, idDriver, reading);
		obtainReadingSequence(&reading, &endSeq, &idDriver);
	}
	writeResult(championship);
	//system("PAUSE");  //pause en Windows
	getchar();			//pause en Linux
	return 0;
}
/*accio obtainReadingSequence (sor reading: tRaceInfo,
							   sor endSeq: boolea,
							   sor idDriver: enter)*/
void obtainReadingSequence(tRaceInfo *reading, bool *endSeq, int *idDriver)
{
	int aux;
	scanf("%d", &aux);
	*endSeq = (aux == 0);
	if(!endSeq)
	{
		idDriver=aux;
		scanf("%d",&reading->idRace);
		scanf("%f",&reading->timeRace);
		scanf("%f",&reading->kmRace);
	}
}
/*accio processReadingSequence (entsor championship : tChampionship,
								ent idDriver: enter,
								ent reading: tRaceInfo )*/
void processReadingSequence( tChampionship *championship, int idDriver, tRaceInfo reading)
{
		int index;
		int position;

		findDriver(&championship, &idDriver, &index);
		findRace(&championship.drivers[index], &reading, &position);
}
//accio findDriver( ent idDriver: enter, entsor championship: tChampionship, sor index: enter )
void findDriver(int idDrive, tChampionship *championship, int *index)
{
	index=1;
	bool found = FALSE;
	while((!found) && (index<=(championship->numDrivers)))
	{
		found=(championship->drivers[index]).idDriver>=idDriver;
		if (!found)
		{
			index=index+1;
		}
	}
	if((!found)||(championship.drivers[index].idDriver<>idDriver))
	{
		insertDriver(&championship, index, idDriver)
	}
}
//accio findRace (ent reading: tRaceInfo, entsor driver: tDriver, sor pos: enter )
void findRace(tRaceInfo reading, tDriver *driver, int *pos)
{
	pos=1;
	bool found = FALSE;
	while((!found) && (pos<=driver->numRaces))
	{
		found=(driver->dataDriver[pos]).idRace>=reading.idRace;
		if(!found)
		{
			pos=pos+1;
		}
	}
	if((!found) || ((driver->dataDriver[pos]).idRace<>reading.idRace)
	{
		insertRace(&driver, pos, reading);
	}
}
//accio insertDriver(ent idDriver: enter ent index: enter,entsor championship: tChampionship, )
void insertDriver(int idDriver, int index, tChampionship *championship)
{
	int j;
	for (j=championship->numDrivers; j=index;j--)
	{
		championship->drivers[j+1]=championship->drivers[j];
	}
	(championship->drivers[index]).idDriver=idDriver;
	(championship->drivers[index]).numRaces=0;
	championship->numDrivers=championship->numDrivers+1;
}
//accio insertRace(ent reading : tRaceInfo , ent position : enter,entsor driver : tDriver)
void insertRace(tRaceInfo reading, int position, tDriver *driver)
{
	int j;
	for(j=(driver->numRaces);j=position;j--)
	{
		driver->dataDriver[j+1]=driver->dataDriver[j];
	}
	(driver->dataDriver[position]).idRace=reading.idRace;
	(driver->dataDriver[position]).timeRace=reading.timeRace;
	(driver->dataDriver[position]).kmRace=reading.kmRace;
	driver->numRaces=driver->numRaces + 1;
{
//accio writeResult (ent championship: tChampionship)
void writeResult(tChampionship championship)
{
	int j, k;
	float average;
	for(k=1;k=championship.numDrivers;k++)
	{
		writeInteger(championship.drivers[k].idDriver);
		printf(" ");
		for(j=1;j=(championship.drivers[k].numRaces);j++)
		{
			writeInteger(championship.drivers[k].dataDriver[j].idRace);
			printf(" ");
			average=(championship.drivers[k].dataDriver[j].kmRace*60)/(championship.drivers[k].dataDriver[j].timeRace);
			printf("%f",average);
			printf(" ");
		}
	}
}
  #2 (permalink)  
Antiguo 01/12/2010, 14:32
 
Fecha de Ingreso: noviembre-2009
Mensajes: 205
Antigüedad: 15 años
Puntos: 15
Respuesta: No encuentro la solución a los errores

Pega la salida del compilador al menos.
  #3 (permalink)  
Antiguo 01/12/2010, 14:41
 
Fecha de Ingreso: octubre-2006
Mensajes: 169
Antigüedad: 18 años, 1 mes
Puntos: 2
Respuesta: No encuentro la solución a los errores

la pego, disculpa

Código:
Description	Resource	Path	Location	Type
make: *** [practica.o] Error 1	00Practica1		line 0	C/C++ Problem
request for member ‘drivers’ in something not a structure or union	practica.c	/00Practica1	line 82	C/C++ Problem
‘idDriver’ undeclared (first use in this function)	practica.c	/00Practica1	line 91	C/C++ Problem
array subscript is not an integer	practica.c	/00Practica1	line 91	C/C++ Problem
expected expression before ‘>’ token	practica.c	/00Practica1	line 97	C/C++ Problem
request for member ‘drivers’ in something not a structure or union	practica.c	/00Practica1	line 97	C/C++ Problem
expected ‘;’ before ‘}’ token	practica.c	/00Practica1	line 100	C/C++ Problem
array subscript is not an integer	practica.c	/00Practica1	line 109	C/C++ Problem
array subscript is not an integer	practica.c	/00Practica1	line 115	C/C++ Problem
expected expression before ‘>’ token	practica.c	/00Practica1	line 115	C/C++ Problem
expected ‘)’ before ‘{’ token	practica.c	/00Practica1	line 116	C/C++ Problem
expected expression before ‘}’ token	practica.c	/00Practica1	line 119	C/C++ Problem
expected declaration or statement at end of input	practica.c	/00Practica1	line 163	C/C++ Problem
assignment makes pointer from integer without a cast	practica.c	/00Practica1	line 67	C/C++ Problem
passing argument 1 of ‘findDriver’ makes integer from pointer without a cast	practica.c	/00Practica1	line 81	C/C++ Problem
passing argument 2 of ‘findDriver’ from incompatible pointer type	practica.c	/00Practica1	line 81	C/C++ Problem
passing argument 2 of ‘findRace’ from incompatible pointer type	practica.c	/00Practica1	line 82	C/C++ Problem
assignment makes pointer from integer without a cast	practica.c	/00Practica1	line 87	C/C++ Problem
comparison between pointer and integer	practica.c	/00Practica1	line 89	C/C++ Problem
passing argument 1 of ‘insertDriver’ makes integer from pointer without a cast	practica.c	/00Practica1	line 99	C/C++ Problem
passing argument 2 of ‘insertDriver’ makes integer from pointer without a cast	practica.c	/00Practica1	line 99	C/C++ Problem
assignment makes pointer from integer without a cast	practica.c	/00Practica1	line 105	C/C++ Problem
comparison between pointer and integer	practica.c	/00Practica1	line 107	C/C++ Problem
suggest parentheses around assignment used as truth value	practica.c	/00Practica1	line 124	C/C++ Problem
suggest parentheses around assignment used as truth value	practica.c	/00Practica1	line 136	C/C++ Problem
suggest parentheses around assignment used as truth value	practica.c	/00Practica1	line 150	C/C++ Problem
implicit declaration of function ‘writeInteger’	practica.c	/00Practica1	line 152	C/C++ Problem
suggest parentheses around assignment used as truth value	practica.c	/00Practica1	line 154	C/C++ Problem

Etiquetas: encuentro
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:49.