1cfd3bbb56
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
3.4 KiB
3.4 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cpp-do-while-loop | C++ Do/While Loop | Programming_Language | draft | conceptual |
|
B | 0.85 | 2026-07-04 | 2026-07-04 |
|
|
CPP Do/While Loop
🎯 한 줄 통찰 (One-line insight)
This chapter explicitly flags something C's equivalent never called out as its own note: "the semicolon after the while condition is required!" — a small but real syntax trap, since do {...} while(condition) LOOKS like it should end like a regular while loop (no trailing semicolon), but the do/while FORM specifically requires one, unlike every other loop and conditional block in C++. [S1]
🧠 핵심 개념 (Core concepts)
do { ... } while (condition);— executes the block ONCE unconditionally, then checks the condition. [S1]- Required trailing semicolon — unlike
while(...) {...}orif(...) {...}, thedo/whileform's closingwhile(condition)MUST end with a semicolon. [S1] - Guaranteed first execution — runs at least once even if the condition is false immediately. [S1]
- Input-validation pattern — repeatedly prompting via
cin >>until the loop condition fails. [S1]
📖 세부 내용 (Details)
- Standard case with the required semicolon:
int i = 0; do { cout << i << "\n"; i++; } while (i < 5);. [S1] - Guaranteed-once case (condition false at start):
int i = 10; do { cout << "i is " << i << "\n"; i++; } while (i < 5);— still prints once. [S1] - Practical input-validation loop:
int number; do { cout << "Enter a positive number: "; cin >> number; } while (number > 0);. [S1]
⚖️ 모순 및 업데이트 (Contradictions & updates)
- do/while 뒤에는 반드시 세미콜론 필요: while(condition) 뒤에 세미콜론을 빠뜨리기 쉬운 문법적 함정이 있다는 점이 C 챕터에는 없던 별도 주의사항으로 명시됨. [S1]
🛠️ 적용 사례 (Applied in summary)
사용자로부터 양수를 입력받되 0이나 음수가 입력될 때까지 반복해서 물어보는 입력 검증 루프가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
💻 코드 패턴 (Code patterns)
The required trailing semicolon after a do/while loop's condition (C++):
int i = 0;
do {
cout << i << "\n";
i++;
}
while (i < 5); // semicolon required here
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.85
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: C++ Tutorial
- 관련 개념: CPP While Loop RealLife, CPP For Loop, C Do While Loop
- 참조 맥락: while 루프의 변형 — for 루프(For Loop) 챕터로 이어짐.
📚 출처 (Sources)
- [S1] W3Schools — C++ Do/While Loop — https://www.w3schools.com/cpp/cpp_do_while_loop.asp
📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Do/While Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).