docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화

Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
Antigravity Agent
2026-07-05 00:10:59 +09:00
parent a397bc4720
commit 1cfd3bbb56
1495 changed files with 68534 additions and 27 deletions
+68
View File
@@ -0,0 +1,68 @@
---
id: c-files-write
title: "C Write To Files"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["fprintf", "write vs append mode", "C 파일 쓰기"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.86
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["c", "programming-language", "w3schools", "files", "fprintf"]
raw_sources: ["https://www.w3schools.com/c/c_files_write.php"]
applied_in: []
github_commit: ""
---
# [[C Write To Files]]
## 🎯 한 줄 통찰 (One-line insight)
Opening an EXISTING file in `"w"` mode silently DESTROYS its entire prior content the moment `fopen()` succeeds — not when you write, just from opening — the source explicitly warns "you might accidentally erase existing content," meaning `"w"` mode is fundamentally destructive/overwrite-only, and `"a"` (append) exists as the ONLY mode that preserves existing content while adding to it. [S1]
## 🧠 핵심 개념 (Core concepts)
- **`fprintf(fptr, text)`** — writes formatted text to the file pointed to by `fptr`, the file-writing analog of `printf()`. [S1]
- **`"w"` mode is destructive** — opening an existing file for writing immediately discards its old content, even before any `fprintf()` call. [S1]
- **`"a"` (append) mode** — adds new content to the END of the file WITHOUT deleting what's already there. [S1]
- **`"a"` also creates missing files** — just like `"w"`, appending to a non-existent file creates it fresh with the appended content as its initial content. [S1]
## 📖 세부 내용 (Details)
- Writing (and overwriting) content: `fptr = fopen("filename.txt", "w"); fprintf(fptr, "Some text"); fclose(fptr);` — then reopening with `"w"` again and writing `"Hello World!"` COMPLETELY replaces "Some text". [S1]
- Appending without erasing prior content: `fptr = fopen("filename.txt", "a"); fprintf(fptr, "\nHi everybody!"); fclose(fptr);` — preserves whatever was already in the file. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **"w" 모드는 열자마자 기존 내용을 지움**: 이미 존재하는 파일을 "w" 모드로 열면 새 내용을 쓰기 전에 이미 기존 내용이 사라진다는 점이 명시적으로 경고되며, 실수로 기존 데이터를 날릴 수 있다는 주의사항이 강조됨. [S1]
## 🛠️ 적용 사례 (Applied in summary)
"Some text"를 쓴 뒤 같은 파일을 다시 "w" 모드로 열어 "Hello World!"로 덮어쓰는 예제가 기존 내용이 완전히 사라지는 것을 직접 보여주는 실전 경고 사례다. [S1]
## 💻 코드 패턴 (Code patterns)
Appending to a file without erasing its existing content (C):
```c
FILE *fptr;
fptr = fopen("filename.txt", "a"); // append mode preserves existing content
fprintf(fptr, "\nHi everybody!");
fclose(fptr);
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.86
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C Tutorial]]
- **관련 개념:** [[C Files Read]], [[C Files]], [[C Type Conversion]]
- **참조 맥락:** 파일 섹션 마지막 — 타입 변환 및 매크로(Type Conversion & Macros) 섹션으로 이어짐.
## 📚 출처 (Sources)
- [S1] W3Schools — C Write To Files — https://www.w3schools.com/c/c_files_write.php
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C Write To Files" page (Astra wiki-curation, P-Reinforce v3.1 format).