1cfd3bbb56
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
3.5 KiB
3.5 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-strings-input | C++ User Input Strings | Programming_Language | draft | conceptual |
|
B | 0.86 | 2026-07-04 | 2026-07-04 |
|
|
CPP User Input Strings
🎯 한 줄 통찰 (One-line insight)
cin >> has the EXACT SAME whitespace-termination limitation as C's scanf("%s", ...) — typing "John Doe" only captures "John" — and C++'s fix (getline(cin, fullName)) mirrors C's fgets() fix conceptually, both existing specifically to read a full line including spaces, meaning this particular parsing limitation and its solution transferred from C to C++ despite the completely different I/O syntax (>>/cin versus scanf/format-strings). [S1]
🧠 핵심 개념 (Core concepts)
cin >> variable— the extraction operator, reads user input into a variable. [S1]cin's whitespace-termination limitation — treats spaces as a terminator, so it can only capture a SINGLE WORD even if the user types multiple words. [S1]getline(cin, variable)— reads a FULL LINE of text including spaces; takescinas the first parameter and the target string as the second. [S1]
📖 세부 내용 (Details)
- Basic single-word input:
string firstName; cin >> firstName;. [S1] - The space-termination trap demonstrated:
string fullName; cin >> fullName; // "John Doe" typed → only "John" stored. [S1] - The
getline()fix for multi-word input:string fullName; getline (cin, fullName); // "John Doe" typed → "John Doe" stored in full. [S1]
⚖️ 모순 및 업데이트 (Contradictions & updates)
- cin >>은 공백에서 끊김: "John Doe"를 입력해도 공백을 종료 문자로 취급해 "John"만 저장된다는 점이 C의 scanf("%s") 문제와 동일하게 확인되며, getline()이 fgets()와 동일한 역할의 해결책으로 제시됨. [S1]
🛠️ 적용 사례 (Applied in summary)
사용자의 전체 이름(공백 포함)을 정확히 입력받기 위해 cin >> 대신 getline()을 사용하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
💻 코드 패턴 (Code patterns)
Reading a full line of text (including spaces) with getline() instead of cin >> (C++):
string fullName;
cout << "Type your full name: ";
getline(cin, fullName);
cout << "Your name is: " << fullName; // "John Doe" prints in full
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.86
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: C++ Tutorial
- 관련 개념: CPP Strings Esc, CPP Strings Length, C User Input
- 참조 맥락: 사용자 입력 문자열 — 문자열 길이(Strings Length) 챕터로 이어짐.
📚 출처 (Sources)
- [S1] W3Schools — C++ User Input Strings — https://www.w3schools.com/cpp/cpp_strings_input.asp
📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ User Input Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).