ERRORES CON PUNTEROS A ARRAYS DE ESTRUCTURAS.
Publicado por maykel (2 intervenciones) el 07/02/2010 13:38:04
Hola Chic@s.
Tengo el siguiente codigo en C:
*********************************************************************************************************************
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CIERTO 1
#define FALSO 0
#define MAXNOMBRE 30
#define MAXTLF 15
#define MAXALUMNOS 2
#define MAXNOTAS 2
#define MAXASIG 15
typedef short int LOGICO;
typedef struct rnota
{
char asignatura[MAXASIG];
float nota;
}Rnota;
typedef Rnota TRnotas[MAXNOTAS];
typedef TRnotas Notas;
typedef struct Ralumno
{
char nombre[MAXNOMBRE];
char tlf[MAXTLF];
Notas notas;
}Ralumno;
typedef Ralumno Talumnos[MAXALUMNOS];
typedef Talumnos Grupo;
void LeerAlumnos(Ralumno *pcl);
int main(int argc, char** argv) {
Grupo clase;
Ralumno *pclase;
int i;
LeerAlumnos(pclase);
return (EXIT_SUCCESS);
}
void LeerAlumnos(Ralumno *pcl)
{
int i,j;
char aux;
printf("\nLeyendo Alumnos. pclase apunta a: %p. y pnotas a %p.\n",pcl,pcl->notas);
for(i=0;i<MAXALUMNOS;i++)
{
printf("\nIntroduzca Nombre del Alumno %i: ",i);
fgets(pcl->nombre,MAXNOMBRE,stdin);
printf("\nIntroduzca Tlf del Alumno %i: ",i);
fgets(pcl->tlf,MAXTLF,stdin);
printf("\nRecogiendo Notas del Alumno: %s.\n",pcl->nombre);
for(j=0;j<MAXNOTAS;j++)
{
printf("\nIntroduzca Nombre Asignatura %i: ",j);
fgets(pcl->notas->asignatura,MAXASIG,stdin);
printf("\nIntroduzca Nota Asignatura %s: ",pcl->notas->asignatura);
scanf("%f",&pcl->notas->nota);
scanf("%c",&aux);
pcl->notas++; //ME DA ERROR AQUI Y NO SE PORQUE..........
}
pcl++;
}
}
*********************************************************************************************************************
El error que me da en la instrucción ( " pcl->notas++; ") es el siguiente:
error: lvalue required as increment operand
La verdad no entiendo porque me da error en ese incremento y no me da en el de abajo (" pcl++; "). He probado incluso poniendole paréntesis así: pcl->(notas++); e incluso así: (pcl->notas++); y siempre me da el mismo error.
¿ALGUN MASTER SABE DE QUE SE PUEDE TRATAR.?.
Tengo el siguiente codigo en C:
*********************************************************************************************************************
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CIERTO 1
#define FALSO 0
#define MAXNOMBRE 30
#define MAXTLF 15
#define MAXALUMNOS 2
#define MAXNOTAS 2
#define MAXASIG 15
typedef short int LOGICO;
typedef struct rnota
{
char asignatura[MAXASIG];
float nota;
}Rnota;
typedef Rnota TRnotas[MAXNOTAS];
typedef TRnotas Notas;
typedef struct Ralumno
{
char nombre[MAXNOMBRE];
char tlf[MAXTLF];
Notas notas;
}Ralumno;
typedef Ralumno Talumnos[MAXALUMNOS];
typedef Talumnos Grupo;
void LeerAlumnos(Ralumno *pcl);
int main(int argc, char** argv) {
Grupo clase;
Ralumno *pclase;
int i;
LeerAlumnos(pclase);
return (EXIT_SUCCESS);
}
void LeerAlumnos(Ralumno *pcl)
{
int i,j;
char aux;
printf("\nLeyendo Alumnos. pclase apunta a: %p. y pnotas a %p.\n",pcl,pcl->notas);
for(i=0;i<MAXALUMNOS;i++)
{
printf("\nIntroduzca Nombre del Alumno %i: ",i);
fgets(pcl->nombre,MAXNOMBRE,stdin);
printf("\nIntroduzca Tlf del Alumno %i: ",i);
fgets(pcl->tlf,MAXTLF,stdin);
printf("\nRecogiendo Notas del Alumno: %s.\n",pcl->nombre);
for(j=0;j<MAXNOTAS;j++)
{
printf("\nIntroduzca Nombre Asignatura %i: ",j);
fgets(pcl->notas->asignatura,MAXASIG,stdin);
printf("\nIntroduzca Nota Asignatura %s: ",pcl->notas->asignatura);
scanf("%f",&pcl->notas->nota);
scanf("%c",&aux);
pcl->notas++; //ME DA ERROR AQUI Y NO SE PORQUE..........
}
pcl++;
}
}
*********************************************************************************************************************
El error que me da en la instrucción ( " pcl->notas++; ") es el siguiente:
error: lvalue required as increment operand
La verdad no entiendo porque me da error en ese incremento y no me da en el de abajo (" pcl++; "). He probado incluso poniendole paréntesis así: pcl->(notas++); e incluso así: (pcl->notas++); y siempre me da el mismo error.
¿ALGUN MASTER SABE DE QUE SE PUEDE TRATAR.?.
Valora esta pregunta


0