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

**URL:** <https://forum.codecrafters.io/t/c-cant-get-stdout-to-output-in-tests/585>\
**Category:** Bug Reports\
**Created:** [June 1, 2024, 9:50pm UTC](https://forum.codecrafters.io/t/c-cant-get-stdout-to-output-in-tests/585 "2024-06-01T21:50:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastienldegroof](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/sebastienldegroof/32/536_2.png) [@sebastienldegroof](https://forum.codecrafters.io/u/sebastienldegroof)\
**Post date:** [June 1, 2024, 9:50pm UTC](https://forum.codecrafters.io/t/c-cant-get-stdout-to-output-in-tests/585/1 "2024-06-01T21:50:24Z")

</div>

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:

#include   
#include   
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.

---

<div class="post-metadata">

**Author:** ![sebastienldegroof](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/sebastienldegroof/32/536_2.png) [@sebastienldegroof](https://forum.codecrafters.io/u/sebastienldegroof)\
**Post date:** [June 1, 2024, 10:28pm UTC](https://forum.codecrafters.io/t/c-cant-get-stdout-to-output-in-tests/585/2 "2024-06-01T22:28:51Z")

</div>

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;

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [June 2, 2024, 2:00pm UTC](https://forum.codecrafters.io/t/c-cant-get-stdout-to-output-in-tests/585/3 "2024-06-02T14:00:51Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [June 9, 2024, 2:01pm UTC](https://forum.codecrafters.io/t/c-cant-get-stdout-to-output-in-tests/585/4 "2024-06-09T14:01:23Z")

</div>

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