학습 내용 : 문자열에서 숫자 문자를 판별하는 방법을 이해합니다.
소스 코드 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
void main()
{
char *string = "Today 2020.03.04";
char buffer[100] = {0,};
int count = 0;
while(*string)
{
if (isdigit(*string))
{
buffer[count] = *string;
count++;
}
string++;
}
puts(buffer);
}
|
실행 화면 :

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