학습 내용 : 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.14e10;
double value2 = -3.14e10;
char *pstr;
int dec;
int sign;
pstr = ecvt(value1, 3, &dec, &sign);
puts(pstr);
printf("소수점의 위치는 %d, 부호는 %d입니다.\n", dec, sign);
pstr = ecvt(value2, 3, &dec, &sign);
puts(pstr);
printf("소수점의 위치는 %d, 부호는 %d입니다.\n", dec, sign);
}
|
실행 화면 :

'프로그래밍 > C언어 300제' 카테고리의 다른 글
중급 89. 문자가 알파벳인지 검사하기 (isalpha) (0) | 2020.03.04 |
---|---|
중급 88. 실수를 문자열로 변환하기 3 (gcvt) (0) | 2020.03.04 |
중급 86. 실수를 문자열로 변환하기 1 (fcvt) (0) | 2020.03.04 |
중급 85. 정수를 문자열로 변환하기 3 (_ultoa) (0) | 2020.03.02 |
중급 84. 정수를 문자열로 변환하기 2 (ltoa) (0) | 2020.03.02 |
트랙백 , 댓글 가 달렸습니다.