728x90
반응형
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int* pi;
	double* pd;

	pi = (int*)malloc(sizeof(int));
	if (pi == NULL)
	{
		printf("# Not enough memory.\n");
		exit(1);
	}

	pd = (double*)malloc(sizeof(double));

	*pi = 10;
	*pd = 3.4;

	printf("integer : %d\n", *pi);
	printf("float : %.1lf\n", *pd);

	free(pi);
	free(pd);

	return 0;
}
728x90
반응형

'Language > C & C++' 카테고리의 다른 글

Number guessing game in Python 3 and C  (0) 2022.08.31
malloc exam  (0) 2022.08.30
the difference between Parameter and Argument  (0) 2022.08.30
Tip for arrays  (0) 2022.08.29
HGC - Chapter 9 exam  (0) 2022.08.29

+ Recent posts