학습 내용 : 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);
}

 

 

실행 화면 :