Skip to content

jglara/ccwc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coding challenges

This is a clone of the Unix command line tool wc. See https://codingchallenges.fyi/challenges/challenge-wc/

I Tried to use Modern c++ with C++23 features, like

  • std::expected for error handling
  • ranges and views to iterate over input stream in one pass
  • std::variant for the different counting options

For the part of locale I tried using https://en.cppreference.com/w/c/string/multibyte/mbrtowc, but I could not make it work like wc -m; it gave a different count; so I had to ask chatgpt for help; so CharCounter implementation credit goes to chatgpt.

Building & Testing

Requirements

  • CMake 3.20 or newer (presets are used to drive the build)
  • A C++23-capable compiler (tested with GCC 13+)
  • Ninja or another CMake-supported generator (the presets default to Ninja)

Configure & Build

# Generate the debug build tree (only needed once or after changing presets)
cmake --preset debug

# Compile the project (incremental by default)
cmake --build --preset debug

For an optimized binary, switch the preset to release in both commands.

Run Tests

cmake --build --preset debug              # ensure the tests are up to date
ctest --preset debug --output-on-failure  # run the suite with verbose failures

Run Benchmarks

cmake --preset release
cmake --build --preset release                 # builds ccwc_bench (downloads Google Benchmark the first time)
build/release/ccwc_bench --benchmark_min_time=100ms

Adjust the --benchmark_min_time value to stabilize results on your machine.

About

Coding Challenges: wc clone

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors