학습 내용 : printf() 함수를 사용하지 않고, 실수값을 문자열로 변환하는 기본 원리를 이해합니다.

 

소스 코드 :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
 
void main()
{
    double value1 = 3.141592;
    double value2 = -3.141592;
    char *pstr;
    int dec;
    int sign;
 
    pstr = fcvt(value1, 6&dec, &sign);
    puts(pstr);
    printf("소수점의 위치는 %d, 부호는 %d입니다.\n", dec, sign);
 
    pstr = fcvt(value2, 8&dec, &sign);
    puts(pstr);
    printf("소수점의 위치는 %d, 부호는 %d입니다.\n", dec, sign);
}
 

 

 

실행 화면 :