학습 내용 : atoi() 함수와 비슷한 기능을 하는 atol() 함수에 대해 학습합니다.
소스 코드 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#include <stdio.h>
#include <stdlib.h>
void main()
{
char *string1 = "2020.03.02 yesterday";
char *string2 = "yesterday 2020.03.02";
int tempInt1 = -1;
int tempInt2 = -1;
puts(string1);
puts(string2);
tempInt1 = atol(string1);
tempInt2 = atol(string2);
printf("%d\n", tempInt1);
printf("%d\n", tempInt2);
}
|
실행 화면 :

'프로그래밍 > C언어 300제' 카테고리의 다른 글
중급 80. 문자열을 정수로 변환하기 4 (strtoul) (0) | 2020.03.02 |
---|---|
중급 79. 문자열을 정수로 변환하기 3 (strtol) (0) | 2020.03.02 |
중급 77. 문자열을 정수로 변환하기 1 (atoi) (0) | 2020.02.26 |
중급 76. 문자열을 형식화하기 (sprintf) (0) | 2020.02.26 |
중급 75. 문자열을 중복 생성하기 (strdup) (0) | 2020.02.26 |
트랙백 , 댓글 가 달렸습니다.