You are on page 1of 3

Ejemplo1:

Forma a)
#include<stdio.h>
struct card{
int cel;
int edad;
};
main(){
struct card a;
a.cel=5543;
a.edad=17;
printf("%d",a.edad);
}
forma b)
#include<stdio.h>
struct card{
int cel;
int edad;
}a;
main (){
a.cel=5543;
a.edad=17;
printf("%d",a.edad);
}
---------------------------------------------------------------------------------------------------INICIALIZACION:
Int:
#include<stdio.h>
struct card{
int cel;
int edad;
};
main(){
struct card a={2,3};
printf("%d",a.edad);
}
---------------------------------------------------------------------------------------------------------

#include<stdio.h>
struct card{
int cel;
int edad;
}a={2,3};
main(){

printf("%d",a.edad);
}
---------------------------------------------------------------------------------------------------------Char
#include<stdio.h>
struct card{
char nombre[30];
char apellido[20];

};
main(){
struct card a={"Rodrigo","Gutierrez"};

printf("%s %s",a.nombre,a.apellido);
}
Arreglo
#include<stdio.h>
#include<stdlib.h>
main(){
int b=20;

int *aptr;
aptr=&b;
printf("%d\n",*aptr);
system("pause");
}
Estructura con arreglos
#include<stdio.h>
#include<stdlib.h>
struct card {
char face[30];
char suit[20];
}a={"ace","spades"};
main(){
struct card *aptr;
aptr=&a;
printf("%s\n%s\n%s\n%s\n%s\n%s\n",a.face,a.suit,aptr->face,aptr->suit,
(*aptr).face,(*aptr).suit);

You might also like