C Example: Text Normalizer: Trim, Collapse Spaces and Title Case

🗓 Last updated: 2026-11-30👤 Written by: Gray✓ Reviewed by: MOTO🏷 Category: Text Processing

A complete command-line text cleaner: trims leading/trailing whitespace, collapses runs of spaces, converts to title case, and reports word/character counts after cleaning. Three inputs cover a normal sentence, a messy-spacing sentence and an empty-string edge case.

🌱 Beginner Reference entries: fn-strlenfn-toupperfn-isdigit
🖥 Run OnlineGCC 10.2 · C11 standard · click ▶ to run · Copy code
🖨 Reference OutputMatches the online run in a standard C11 environment
C · GCC 10.2 · -std=c11
[1] greeting
  cleaned   : "hello WORLD from C"
  words=4 chars=18
  title-case: "Hello World From C"

[2] sentence
  cleaned   : "the quick brown fox jumps over the lazy dog"
  words=9 chars=43
  title-case: "The Quick Brown Fox Jumps Over The Lazy Dog"

[3] empty
  cleaned   : ""
  words=0 chars=0
  title-case: ""
🧩 Keep Learning

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏