중급 78. 문자열을 정수로 변환하기 2 (atol)

학습 내용 : atoi() 함수와 비슷한 기능을 하는 atol() 함수에 대해 학습합니다. 소스 코드 : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #include #include 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); } 실행 화면 :

중급 77. 문자열을 정수로 변환하기 1 (atoi)

학습 내용 : 문자열을 숫자 값으로 변환하는 기본 원리를 학습합니다. 소스 코드 : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include #include void main() { int count; int total = 0; char string[100]; for (count = 0; count

중급 76. 문자열을 형식화하기 (sprintf)

학습 내용 : printf() 함수와 사용법이 같은 sprintf() 함수의 사용법을 이해합니다. 소스 코드 : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #include void main() { char cValue = 'a'; int iValue = 1234567; long lValue = 7890123; float fValue = 3.141592; double dValue = 3.141592; char *string = "Korea"; char buffer[100]; sprintf(buffer, "char 형은 %c", cValue); puts(buffer); sprintf(buffer, "int ..