Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- 선그래프
- 알고리즘 스터디
- 프로그래머스
- pandas
- NumPy
- 정보처리기사 c언어
- queue
- python
- 파이썬
- Algorithm
- 알고리즘스터디
- programmers
- 데이터시각화
- Selenium
- javascript
- type hint
- 자료구조
- 알고리즘
- 코딩테스트
- openCV
- dataframe
- String Method
- Stack
- aws jupyter notebook
- MySQL
- Join
- 백준
- 노마드코딩
- Matplotlib
- 가상환경
Archives
- Today
- Total
조금씩 꾸준히 완성을 향해
[C 언어] printf 함수 & 단항 연산자(++, --) 출력 순서 본문
printf 함수 & 단항 연산자(++, --)
- printf()함수 - 뒤에서부터 연산을 시작!!
- 단항 연산자가 변수 앞에 있을 경우(++i, --i) - 최종 연산이 끝난 후의 i의 값을 참조 = printf 연산을 하는 시점의 i의 값 참조
▶ printf & ++i
#include <stdio.h>
int main() {
int i = 5;
printf("%d, %d, %d, %d", i++, ++i, i++, ++i);
}
// 8, 9, 6, 9
▶ printf & --i
#include <stdio.h>
int main() {
int i = 5;
printf("%d, %d, %d, %d", --i, i--, i--, --i);
}
// 1, 3, 4, 1
▶ printf & i
※ 단항 연사자가 없는 그냥 i의 경우에도 모든 연산이 끝난 후의 i값 참조
#include <stdio.h>
int main() {
int i = 5;
printf("%d, %d, %d, %d", --i, i--, i--, i, --i);
}
// 1, 3, 4, 1, 1
※ 유튜브 흥달쌤 깨알 C언어 특강을 직접 정리한 내용입니다
'기타 언어 > C 언어' 카테고리의 다른 글
| [C 언어] fork 함수 (0) | 2023.03.31 |
|---|---|
| [C 언어] 단항 연산자(++, --) 같은 변수로 중복 (0) | 2023.03.31 |
| [ C 언어] 중복 재귀함수 (0) | 2023.03.29 |
| [C 언어] 재귀 함수 (0) | 2023.03.29 |
| [C 언어] 정적(STATIC) 변수 (0) | 2023.03.29 |