Skip to content

Commit

Permalink
Merge pull request #76 from codecrafters-io/CC-1237
Browse files Browse the repository at this point in the history
CC-1237: Use autoflush using std::unitbuf for c++ repos
  • Loading branch information
ryan-gang authored May 29, 2024
2 parents 7702be0 + a0ffb12 commit 032f02b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions compiled_starters/cpp/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ bool match_pattern(const std::string& input_line, const std::string& pattern) {
}

int main(int argc, char* argv[]) {
// Flush after every std::cout / std::cerr
std::cout << std::unitbuf;
std::cerr << std::unitbuf;

// You can use print statements as follows for debugging, they'll be visible when running tests.
std::cout << "Logs from your program will appear here" << std::endl;

Expand Down
4 changes: 4 additions & 0 deletions solutions/cpp/01-cq2/code/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ bool match_pattern(const std::string& input_line, const std::string& pattern) {
}

int main(int argc, char* argv[]) {
// Flush after every std::cout / std::cerr
std::cout << std::unitbuf;
std::cerr << std::unitbuf;

if (argc != 3) {
std::cerr << "Expected two arguments" << std::endl;
return 1;
Expand Down
6 changes: 5 additions & 1 deletion solutions/cpp/01-cq2/diff/src/Server.cpp.diff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -1,45 +1,40 @@
@@ -1,49 +1,44 @@
#include <iostream>
#include <string>

Expand All @@ -12,6 +12,10 @@
}

int main(int argc, char* argv[]) {
// Flush after every std::cout / std::cerr
std::cout << std::unitbuf;
std::cerr << std::unitbuf;

- // You can use print statements as follows for debugging, they'll be visible when running tests.
- std::cout << "Logs from your program will appear here" << std::endl;
-
Expand Down
4 changes: 4 additions & 0 deletions starter_templates/cpp/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ bool match_pattern(const std::string& input_line, const std::string& pattern) {
}

int main(int argc, char* argv[]) {
// Flush after every std::cout / std::cerr
std::cout << std::unitbuf;
std::cerr << std::unitbuf;

// You can use print statements as follows for debugging, they'll be visible when running tests.
std::cout << "Logs from your program will appear here" << std::endl;

Expand Down

0 comments on commit 032f02b

Please sign in to comment.