Video Coming Soon...

Created by Zed A. Shaw Updated 2026-11-26 20:48:52
 

46: tr

WARNING: This is from the Go course but I'm rewriting the code and the description to fit C. If you want to attempt it go ahead. The challenge is the same, just no examples yet.

The tr command is another very useful tool that "translates" one set of characters to another set. It reads the input, looks at each character, and changes any that match the input set to the output set.

Most of the documentation for tr talks about "array1 and array1" which are just the two sets of characters you give tr as command line options.

The Challenge

You are required to implement the following options to tr:

  • -c -- Compliment of array1, which means inverse, so every character not in array1.
  • -d -- Delete chars that match array1.
  • -s -- Squeeze the characters found in array2, which means to remove duplicates.
  • -t -- Truncate array1 to array2 length.

You can find the documentation for tr here:

Previous Lesson Next Lesson

Register for From Impostor to Programmer

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.