Featured resource
2026 Tech Forecast
2026 Tech Forecast

1,500+ tech insiders, business leaders, and Pluralsight Authors share their predictions on what’s shifting fastest and how to stay ahead.

Download the forecast
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Core Tech
Labs

Create a Minimal C Program

Station Console is a small C utility that remote weather station operators run once per shift. It takes a raw Celsius reading and a station name, validates the reading, converts it to Fahrenheit, and appends a formatted line to the shift's log. Station names come from an international roster and may contain multi-byte UTF-8 characters such as accents, so every buffer operation must be measured in bytes, not assumed characters, and every copy must respect the destination buffer's real capacity. You will build the startup status logic, the conversion functions, the input-to-output pipeline, and the safe string log assembly that main() will eventually call.

Lab platform
Lab Info
Level
Beginner
Last updated
Nov 18, 2026
Duration
45m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use, and consent to receive marketing emails from Pluralsight.
Table of Contents
  1. Challenge

    Step 1: Orient yourself in the Station Console project

    Station Console

    Field technicians at remote weather stations run Station Console once per shift: it takes a raw Celsius reading and a station name, validates the reading, converts it to Fahrenheit, and appends a formatted line to the shift log. Station names come from an international roster, so they may contain multi-byte UTF-8 characters such as accents — every buffer operation in this lab is measured in bytes, never assumed characters.

    Over the next four steps you will write the C functions that main() eventually calls: a startup status check, a small set of temperature functions, an input-parsing-and-formatting pipeline, and a safe string-joining routine for the log itself. ## How the source is laid out

    Your work lives entirely under src/, split into four modules that build on each other:

    • console_status.c / .h — decides and describes the exit status a station reports at startup.
    • temperature_math.c / .h — pure functions for converting, validating, and averaging temperatures.
    • reading_console.c / .h — parses raw numeric input and formats a converted report, calling into temperature_math.h.
    • station_log.c / .h — copies and joins strings into fixed buffers, calling into reading_console.h.

    Each header already declares the functions you'll complete, with an include guard, so the corresponding test file can link against them as soon as the body exists. ## What's ahead

    Step 2 starts with the smallest piece: turning two basic-type readings (a sensor flag and a battery percentage) into one of a few defined exit status codes. From there, each step adds one layer — temperature math, then parsing and formatting, then the UTF-8-aware string handling that ties a station name to its reading in the final log line. Every task you complete is called, directly or indirectly, by the one after it.

    info> If you get stuck, you can refer to the provided solution code for each task, available in the solution folder.

  2. Challenge

    Step 2: Report the console's startup exit status

    Exit statuses from basic-type checks

    console_status.h declares a handful of int constants such as STATUS_OK, STATUS_SENSOR_FAULT, and STATUS_LOW_BATTERY. A startup check in C is usually nothing more than comparing a few basic-type variables — an int flag, an int percentage — against thresholds and returning the matching constant. Getting the order of those comparisons right matters: whichever condition you check first wins when more than one is true. ## From a code to a message

    A status constant is only useful to the program; a technician needs a string. The second half of this module maps each constant back to readable text, with a fallback for anything unexpected.

  3. Challenge

    Step 3: Organize temperature logic into callable functions

    Small functions, clear contracts

    temperature_math.h declares three independent functions, each with explicit parameters and a return value — no shared state, no side effects. Splitting temperature logic this way means every piece can be tested, and reused, on its own. First up is the most fundamental one: converting a single value from Celsius to Fahrenheit. ## Validating a reading

    Not every number a sensor produces is safe to log. is_reading_in_range takes the same kind of basic-type parameters — a value and two bounds — and returns an int-as-boolean result, the same convention console_status.c used for its status codes. ## Summarizing a shift

    A shift often produces several readings, not one. average_readings takes a pointer to an array and a count — the standard C way of passing a variable-length list to a function — and must handle the edge case of an empty batch without crashing.

  4. Challenge

    Step 4: Read a reading and format its converted output

    From text to a number

    Raw input arrives as a line of text, not a double. reading_console.h declares parse_celsius_input, which uses the standard library's strtod to convert text to a number while also detecting text that isn't numeric at all — the difference between a valid reading and an operator's typo. ## Formatting the converted value

    Once you have a Celsius double, you need a line of output a technician can read. format_fahrenheit_report calls the conversion function from Step 3 and writes the result into a caller-supplied buffer with snprintf, which — unlike sprintf — never writes past the buffer's stated size. ## One pipeline, one result

    build_reading_report is the function main() will actually call: it strings parsing and formatting together and reduces the outcome to a single success/failure flag, so nothing downstream needs to know how the parsing or formatting happened underneath.

  5. Challenge

    Step 5: Assemble the station's log entry safely

    Capacity is not the same as length

    A destination buffer's capacity — how many bytes it can physically hold — is a fact about the buffer. A string's length, from strlen, is a fact about the data. copy_station_name has to reconcile the two: it must never write more bytes than the buffer can hold, and it must always leave room for the terminating null byte, regardless of how long the incoming name is. ## Truncating without breaking a character

    UTF-8 encodes some characters, like accented letters, as two or more bytes. If a truncation cuts a buffer off in the middle of one of those byte sequences, the result is invalid text. Continuation bytes in UTF-8 always have their top two bits set to 10, which is exactly the check join_log_line needs before it decides where to stop. ## Wiring it together

    With copying and joining in place, build_log_entry is the last piece: it calls build_reading_report from Step 4 to get the reading text, then join_log_line to combine it with the station name, producing exactly what a shift log expects for one line.

  6. Challenge

    Step 6: Run the application

    Every task is done, and each one was graded the moment you completed it. What you have not done yet is watch the whole application run at once -- which is the only place the pieces you wrote separately become a single working program.

    Start the application

    Open the Terminal tab and run:

    make app && ./build/release/lab.out
    

    The program runs in the terminal and prints its output there. Every behaviour it shows is code you wrote in the previous steps, so read the output against what each task asked for -- that is the whole lab, working as one program. ### Run the checks yourself

    The lab ran each task's test for you as you went, but they are ordinary tests and you can run them whenever you like. The whole suite:

    make test
    

    Or one task at a time:

    bash runTest.sh test_task_2_1
    

    Each failure names the task it belongs to, so the output tells you which step to go back to rather than which line to stare at. Two things worth trying before you finish: break something on purpose and watch the matching check fail, then put it back. Knowing what a failure looks like is worth as much as knowing what a pass looks like, and it costs you nothing here.

    When you are done, everything you wrote is still in the editor tabs -- the lab is yours to keep reading.

About the author

Pluralsight’s AI authoring technology is designed to accelerate the creation of hands-on, technical learning experiences. Serving as a first-pass content generator, it produces structured lab drafts aligned to learning objectives defined by Pluralsight’s Curriculum team. Each lab is then enhanced by our Content team, who configure the environments, refine instructions, and conduct rigorous technical and quality reviews. The result is a collaboration between artificial intelligence and human expertise, where AI supports scale and efficiency, and Pluralsight experts ensure accuracy, relevance, and instructional quality, helping learners build practical skills with confidence.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight