MemDin: Malloc, entero, float, char

03 malloc.html
#include <stdio.h>
#include <stdlib.h>

int main(){
	int *a;
	float *b;
	char *c;
	//int x;
	
	a = malloc(sizeof(int));
	b = malloc(sizeof(float));
	c = malloc(sizeof(char));
	
	*a = 5;
	*b = 5.54;
	*c = 'h';
	
	printf("Un entero: %d \n",*a);
	printf("Un float: %.2f \n",*b);
	printf("Un caracter: %c \n",*c);
	
	//x = sizeof(int);
	//printf("%d ",x);	
	
	system("pause");
	return 0;
}

No hay comentarios:

Publicar un comentario