C++: Can't get stdout to output in tests

I’ve made it through about 20 stages of the redis challenge without getting any output from stdout, but I’m spinning my wheels now as I’ve been unable to replicate the failures in my own environment. How do we get output from stdout to display during the tests? I’ve tried the following while also enabling debug mode in the codecrafters.yml file:

std::cout << “RESP message received: \n”;
std::fprintf(stdout, “RESP message received: \n”);
printf(“RESP message received: \n”);

Is there another setting somewhere I’ve missed? The logs display when running on my machine.

Figured it out. Printing \n isn’t enough to flush the cout buffer. Using std::endl flushed the cout buffer and printed the logs.

std::cout << "RESP message received: " << std:endl;

1 Like

Ah, we just pushed a change last week to fix this in starter repos for C & C++ :slight_smile: CC-1237: Use autoflush using std::unitbuf for c++ repos by ryan-gang · Pull Request #209 · codecrafters-io/build-your-own-redis · GitHub

If anyone is still running into issues w/ stdout buffering for C/C++, please let us know!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.