Files
2nd/10_Wiki/Dev/Topic_C/C_Strings.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

4.0 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
c-strings C Strings Programming_Language draft conceptual
char array
null terminator
C 문자열
B 0.87 2026-07-04 2026-07-04
c
programming-language
w3schools
strings
https://www.w3schools.com/c/c_strings.php

C Strings

🎯 한 줄 통찰 (One-line insight)

C has no true String type at all — a string is just an array of chars ending in a special \0 null-terminator character, proven directly by the fact that sizeof() reports the SAME size (13 bytes) whether the string was written as a convenient literal ("Hello World!") or manually spelled out character-by-character with an explicit \0 at the end ({'H','e',...,'!','\0'}) — the literal syntax is pure convenience, not a different underlying type. [S1]

🧠 핵심 개념 (Core concepts)

  • No dedicated String type — a C "string" is a char array; char greetings[] = "Hello World!"; is the idiomatic way to create one. [S1]
  • %s format specifier — used to print an entire string (as opposed to %c for a single character). [S1]
  • Index access — since a string is an array, greetings[0] accesses its first character, printed with %c. [S1]
  • Mutable characters — individual characters can be reassigned via index (greetings[0] = 'J';), changing the string in place. [S1]
  • Null terminator (\0) — required at the end of a manually-built character-list string; string literals get it added automatically. [S1]
  • Loop-through pattern — iterating a string's characters via a for loop, ideally using sizeof(arr)/sizeof(arr[0]) for the length instead of a hardcoded number. [S1]

📖 세부 내용 (Details)

  • Modifying a single character: char greetings[] = "Hello World!"; greetings[0] = 'J'; printf("%s", greetings); // Outputs Jello World!. [S1]
  • Manual character-list construction requiring an explicit null terminator: char greetings[] = {'H','e','l','l','o',' ','W','o','r','l','d','!','\0'};. [S1]
  • Proving both construction methods produce identically-sized arrays: printf("%zu\n", sizeof(greetings)); // 13 and printf("%zu\n", sizeof(greetings2)); // 13 (literal form auto-adds \0). [S1]

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

  • 문자열 리터럴과 수동 문자 나열의 동등성: 두 방식 모두 결국 동일한 크기(13바이트, \0 포함)의 char 배열을 만든다는 점이 sizeof 비교로 직접 증명됨 — 리터럴은 단지 \0을 자동으로 추가해주는 편의 문법일 뿐. [S1]

🛠️ 적용 사례 (Applied in summary)

인사말과 이름을 조합해 환영 메시지를 만드는 예제("%s %s!", message, fname)가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Looping through a string's characters using sizeof for a portable length calculation (C):

char carName[] = "Volvo";
int length = sizeof(carName) / sizeof(carName[0]);
int i;
for (i = 0; i < length; ++i) {
  printf("%c\n", carName[i]);
}

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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