UPDATED:
I found the bug, single quotes wrong. Replaced it by double quotes and worked fine. Sorry for the inconvenience but caught it soon.
===========================================================================
This is a simple example of what should be a structure declaration and access to its data, but I get a list of errors complaining that the “character constant is too long for its type” and also “passing of argument 1 in printf makes pointer from integer without a cast”. So, the program crashes with overflow stuff. Nombre is first name, apellido is last name, and edad is age. Was trying to gather all that in a structure and the print the results accessing them through a pointer. (Why do I have to access them through a pointer and not simply by the dot notation?)
#include <stdio.h>
#include <stdlib.h>
struct estructura_amigo {
char nombre[30];
char apellido[40];
char telefono[10];
int edad;
};
struct estructura_amigo amigo = {
'Juanjo',
'Lopez',
'592-0483',
30
};
struct estructura_amigo *p_amigo;
int main()
{
p_amigo = &amigo;
printf( '%s tiene ', p_amigo->apellido );
printf( '%i años ', p_amigo->edad );
printf( 'y su teléfono es el %s.\n' , p_amigo->telefono );
}
Use double quotes, like this
In C single quote = char, double quote = string.
And
should work, no need to get a pointer to the struct.