I have the following code:
#include <stdio.h>
struct datos_nut
{
char nombre[17];
float calorias;
float proteinas;
float colesterol;
float fibradietetica;
};
struct datos_nut *p;
struct datos_nut (*frutos)[4]= &(struct datos_nut[4]){
{"Aguacate", 2.33, 0.018, 0, 0.07},
{"Almendra", 6.1, 0.187, 0, 0.143},
{"Fresa", 0.35, 0.008, 0, 0.002},
{"Berenjena", 0.22, 0.012, 0, 0.0137}
};
void main(void)
{
p = *frutos;
printf("%s",(*p)[3].nombre);
}
When I try to compile it gives me the following error:
[Error] subscripted value is neither array nor pointer nor vector
in the printf() line. Whenever I use p instead of *p it compiles and works perfectly.
Also if I use (*frutos)[3].nombre compile without errors and works, shouldn't it work using *p ?
Can someone point me out what the problem is here and why it works for *frutos but not for *p?
I'm trying this code using DevC++ in Windows 10.