Files
2nd/10_Wiki/Dev/Topic_CPP/CPP_Strings_Length.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

3.3 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-length C++ String Length Programming_Language draft conceptual
length() function
size() alias
C++ 문자열 길이
B 0.83 2026-07-04 2026-07-04
cpp
programming-language
w3schools
strings
length
https://www.w3schools.com/cpp/cpp_strings_length.asp

CPP String Length

🎯 한 줄 통찰 (One-line insight)

length() and size() are explicitly stated to be EXACT ALIASES for each other — not two functions that happen to behave similarly, but literally the same operation under two names — meaning code encountered "in the wild" using size() instead of length() isn't using a different technique, just a different spelling of the identical call, and the choice between them is purely stylistic. [S1]

🧠 핵심 개념 (Core concepts)

  • .length() — returns the number of characters in a string. [S1]
  • .size() — an exact ALIAS of .length(); both do precisely the same thing. [S1]
  • No functional difference — unlike C's sizeof vs strlen distinction (which measure genuinely different things), C++'s length()/size() pair is purely a naming convenience with zero behavioral difference. [S1]

📖 세부 내용 (Details)

  • Getting length via .length(): string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; cout << txt.length(); // 26. [S1]
  • The identical result via .size(): cout << txt.size(); // 26, same result. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • length()와 size()는 완전한 별칭: C의 sizeof/strlen처럼 서로 다른 것을 측정하는 관계가 아니라, C++의 length()와 size()는 정확히 동일한 동작을 하는 두 개의 이름일 뿐이라는 점이 명시적으로 확인됨. [S1]

🛠️ 적용 사례 (Applied in summary)

현재 발견된 실제 적용 사례가 없습니다 — 다른 사람의 C++ 코드에서 size()를 볼 수도 있다는 점을 미리 알아두면 실전 코드 독해에 도움이 된다. [S1]

💻 코드 패턴 (Code patterns)

length() and size() are exact aliases of each other (C++):

string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cout << txt.length(); // 26
cout << txt.size();   // 26, identical result

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.83
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "C++ String Length" page (Astra wiki-curation, P-Reinforce v3.1 format).