#include <stdio.h>
#include <conio.h>
struct alumno {
char cuenta [9];
char nombre [20];
char sexo;
int edad;
float promedio;
};
struct alumno unam;
struct alumno *ptr;
main(){
unam.sexo='M';
unam.edad=18;
unam.promedio=9.45;
ptr=&unam;
printf("\n Sexo :%c",unam.sexo);
printf("\n Edad :%d",ptr->edad);
printf("\n Promedio:%.2f",(*ptr).promedio);
getch();
}
jueves, 15 de diciembre de 2011
miércoles, 14 de diciembre de 2011
Apuntadores
#include <stdio.h>
#include <conio.h>
main(){
int x;
int * ptr, *ptr2;
ptr = &x;
x = 8;
printf("%p", ptr);
printf("\n%p", &ptr);
printf("\n\nx = %d", x);
* ptr = 16;
printf("\n\nAhora x = %d", x);
ptr2= &ptr;
getch();
}
Suscribirse a:
Entradas (Atom)