Skip to content

Commit

Permalink
CC-1237: Use autoflush using std::unitbuf for c++ repos
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-gang committed May 29, 2024
1 parent 7702be0 commit a0ffb12
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 a0ffb12

Please sign in to comment.