C Example: Inverted Index: word-to-line mapping with de-duplication
Builds an inverted index from a three-line document: tokenises each line, lowercases the words, and maps every word to the line numbers where it appears; repeated occurrences on the same line are recorded once. Prints nine terms in first-seen order with their line lists — a miniature search index.
🖥 Run OnlineGCC 10.2 · C11 standard · click ▶ to run · Copy code
🖨 Reference OutputMatches the online run in a standard C11 environment
lines indexed: 3, unique terms: 9 the -> 1 2 3 quick -> 1 brown -> 1 fox -> 1 3 jumps -> 2 over -> 2 lazy -> 2 dog -> 2 sleeps -> 3
🧩 Keep Learning