Print newline character instead of using `std::endl`

pull/8251/head
vil02 3 months ago
parent ecbb625a09
commit d488fcaf91
  1. 4
      src/data/roadmaps/cpp/content/100-introduction/100-what-is-cpp.md
  2. 2
      src/data/roadmaps/cpp/content/100-introduction/101-why-cpp.md
  3. 4
      src/data/roadmaps/cpp/content/100-introduction/index.md
  4. 2
      src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md
  5. 6
      src/data/roadmaps/cpp/content/102-basic-operations/102-loops.md
  6. 4
      src/data/roadmaps/cpp/content/103-functions/index.md
  7. 6
      src/data/roadmaps/cpp/content/104-data-types/100-static-typing.md
  8. 12
      src/data/roadmaps/cpp/content/104-data-types/101-dynamic-typing/index.md
  9. 2
      src/data/roadmaps/cpp/content/104-data-types/index.md
  10. 8
      src/data/roadmaps/cpp/content/105-pointers-and-references/100-references.md
  11. 2
      src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/102-uniqe-ptr.md
  12. 14
      src/data/roadmaps/cpp/content/106-structuring-codebase/100-scope/100-namespaces.md
  13. 12
      src/data/roadmaps/cpp/content/106-structuring-codebase/100-scope/index.md
  14. 8
      src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/100-static-polymorphism/index.md
  15. 6
      src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/100-static-polymorphism/overloading-functions.md
  16. 4
      src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/virtual-methods.md
  17. 2
      src/data/roadmaps/cpp/content/107-structures-and-classes/index.md
  18. 4
      src/data/roadmaps/cpp/content/108-exception-handling/100-exceptions/index.md
  19. 8
      src/data/roadmaps/cpp/content/108-exception-handling/index.md
  20. 4
      src/data/roadmaps/cpp/content/109-language-concepts/100-auto.md
  21. 4
      src/data/roadmaps/cpp/content/109-language-concepts/101-type-casting/101-const-cast.md
  22. 2
      src/data/roadmaps/cpp/content/109-language-concepts/101-type-casting/103-reinterpret-cast.md
  23. 2
      src/data/roadmaps/cpp/content/109-language-concepts/103-adl.md
  24. 2
      src/data/roadmaps/cpp/content/110-stl/101-iostream.md
  25. 2
      src/data/roadmaps/cpp/content/110-stl/103-date-time.md
  26. 4
      src/data/roadmaps/cpp/content/110-stl/104-multithreading.md
  27. 8
      src/data/roadmaps/cpp/content/110-stl/105-ccontainers.md
  28. 4
      src/data/roadmaps/cpp/content/111-templates/100-variadic-templates.md
  29. 6
      src/data/roadmaps/cpp/content/111-templates/101-template-specialization/101-partial.md
  30. 8
      src/data/roadmaps/cpp/content/111-templates/101-template-specialization/index.md
  31. 6
      src/data/roadmaps/cpp/content/111-templates/102-type-traits.md
  32. 2
      src/data/roadmaps/cpp/content/113-standards/100-cpp11-14.md
  33. 2
      src/data/roadmaps/cpp/content/113-standards/102-cpp20.md
  34. 2
      src/data/roadmaps/cpp/content/113-standards/104-cpp0x.md
  35. 2
      src/data/roadmaps/cpp/content/113-standards/index.md
  36. 2
      src/data/roadmaps/cpp/content/114-debuggers/100-debugger-messages.md
  37. 2
      src/data/roadmaps/cpp/content/114-debuggers/103-gdb.md
  38. 2
      src/data/roadmaps/cpp/content/115-compilers/100-stages.md
  39. 10
      src/data/roadmaps/cpp/content/frameworks/104-pytorch-cpp.md
  40. 6
      src/data/roadmaps/cpp/content/libraries/102-poco.md
  41. 6
      src/data/roadmaps/cpp/content/libraries/103-protobuf.md
  42. 4
      src/data/roadmaps/cpp/content/libraries/104-grpc.md
  43. 2
      src/data/roadmaps/cpp/content/libraries/108-opencl.md

@ -32,12 +32,12 @@ int main() {
// Using the standalone function 'add'
int sum = add(x, y);
std::cout << "Sum: " << sum << std::endl;
std::cout << "Sum: " << sum << '\n';
// Using a class and member function
Calculator calc;
int product = calc.multiply(x, y);
std::cout << "Product: " << product << std::endl;
std::cout << "Product: " << product << '\n';
return 0;
}

@ -43,7 +43,7 @@ int main() {
// High-level programming
std::vector<int> myVector = {1, 2, 3};
for (const auto &i: myVector) {
std::cout << i << std::endl;
std::cout << i << '\n';
}
}
```

@ -36,7 +36,7 @@ int main() {
int number;
std::cout << "Enter an integer: ";
std::cin >> number;
std::cout << "You entered: " << number << std::endl;
std::cout << "You entered: " << number << '\n';
return 0;
}
```
@ -124,7 +124,7 @@ int add(int a, int b) {
int main() {
int result = add(3, 4);
std::cout << "3 + 4 = " << result << std::endl;
std::cout << "3 + 4 = " << result << '\n';
return 0;
}
```

@ -45,7 +45,7 @@ std::cout << "Hello, World!\n";
- `std`: This is the namespace where C++ standard library entities (classes and functions) reside. It stands for "standard" and is an abbreviation for the Standard Template Library (STL).
- `std::cout`: The standard "character output" stream that writes to the console
- `"Hello, World!"`: The string literal to print
- `std::endl`: The "end line" manipulator that inserts a newline character and flushes the output buffer
- `'\n'`: The "end line" manipulator that inserts a newline character and flushes the output buffer
## Return Statement

@ -21,7 +21,7 @@ For example:
int main() {
for (int i = 0; i < 5; i++) {
std::cout << "Iteration: " << i << std::endl;
std::cout << "Iteration: " << i << '\n';
}
return 0;
}
@ -47,7 +47,7 @@ For example:
int main() {
int i = 0;
while (i < 5) {
std::cout << "Iteration: " << i << std::endl;
std::cout << "Iteration: " << i << '\n';
i++;
}
return 0;
@ -74,7 +74,7 @@ For example:
int main() {
int i = 0;
do {
std::cout << "Iteration: " << i << std::endl;
std::cout << "Iteration: " << i << '\n';
i++;
} while (i < 5);
return 0;

@ -36,7 +36,7 @@ int addNumbers(int a, int b) {
int main() {
int num1 = 5, num2 = 10;
int result = addNumbers(num1, num2); // Calling the function
std::cout << "The sum is: " << result << std::endl;
std::cout << "The sum is: " << result << '\n';
return 0;
}
```
@ -58,7 +58,7 @@ int multiplyNumbers(int x, int y);
int main() {
int num1 = 3, num2 = 7;
int result = multiplyNumbers(num1, num2); // Calling the function
std::cout << "The product is: " << result << std::endl;
std::cout << "The product is: " << result << '\n';
return 0;
}

@ -17,9 +17,9 @@ int main() {
c = num; // This asssigment would convert num's value to ASCII equivalent character
num = pi; // This assignment would convert pi's value from double type to int type
std::cout << "The value of num is: " << num << std::endl;
std::cout << "The value of pi is: " << pi << std::endl;
std::cout << "The value of c is: "<< c << std::endl;
std::cout << "The value of num is: " << num << '\n';
std::cout << "The value of pi is: " << pi << '\n';
std::cout << "The value of c is: "<< c << '\n';
return 0;
}
```

@ -20,13 +20,13 @@ int main() {
void* void_ptr;
void_ptr = &x;
std::cout << "int value: " << *(static_cast<int*>(void_ptr)) << std::endl;
std::cout << "int value: " << *(static_cast<int*>(void_ptr)) << '\n';
void_ptr = &y;
std::cout << "float value: " << *(static_cast<float*>(void_ptr)) << std::endl;
std::cout << "float value: " << *(static_cast<float*>(void_ptr)) << '\n';
void_ptr = &z;
std::cout << "string value: " << *(static_cast<std::string*>(void_ptr)) << std::endl;
std::cout << "string value: " << *(static_cast<std::string*>(void_ptr)) << '\n';
return 0;
}
@ -45,13 +45,13 @@ int main() {
std::any any_value;
any_value = 42;
std::cout << "int value: " << std::any_cast<int>(any_value) << std::endl;
std::cout << "int value: " << std::any_cast<int>(any_value) << '\n';
any_value = 3.14;
std::cout << "double value: " << std::any_cast<double>(any_value) << std::endl;
std::cout << "double value: " << std::any_cast<double>(any_value) << '\n';
any_value = std::string("Hello, world!");
std::cout << "string value: " << std::any_cast<std::string>(any_value) << std::endl;
std::cout << "string value: " << std::any_cast<std::string>(any_value) << '\n';
return 0;
}

@ -109,7 +109,7 @@ public:
int age;
void printInfo() {
std::cout << "Name: " << name << ", Age: " << age << std::endl;
std::cout << "Name: " << name << ", Age: " << age << '\n';
};
};

@ -14,10 +14,10 @@ You can use the reference just like you'd use the original variable. When you ch
```cpp
var = 20; // Sets the value of var to 20
std::cout << ref << std::endl; // Outputs 20
std::cout << ref << '\n'; // Outputs 20
ref = 30; // Sets the value of ref to 30
std::cout << var << std::endl; // Outputs 30
std::cout << var << '\n'; // Outputs 30
```
## Function Parameters
@ -31,9 +31,9 @@ void swap(int& a, int& b) {
int main() {
int x = 5, y = 10;
std::cout << "Before Swap: x = " << x << " y = " << y << std::endl; // Outputs 5 10
std::cout << "Before Swap: x = " << x << " y = " << y << '\n'; // Outputs 5 10
swap(x, y);
std::cout << "After Swap: x = " << x << " y = " << y << std::endl; // Outputs 10 5
std::cout << "After Swap: x = " << x << " y = " << y << '\n'; // Outputs 10 5
}
```

@ -18,7 +18,7 @@ int main() {
std::unique_ptr<int> p1(new int(5)); // Initialize with pointer to a new integer
std::unique_ptr<int> p2 = std::make_unique<int>(10); // Preferred method (C++14 onwards)
std::cout << *p1 << ", " << *p2 << std::endl;
std::cout << *p1 << ", " << *p2 << '\n';
return 0;
}
```

@ -27,8 +27,8 @@ namespace animals {
}
int main() {
std::cout << "Dog's name: " << animals::dog << std::endl;
std::cout << "Cat's name: " << animals::cat << std::endl;
std::cout << "Dog's name: " << animals::dog << '\n';
std::cout << "Cat's name: " << animals::cat << '\n';
return 0;
}
@ -50,8 +50,8 @@ namespace outer {
}
int main() {
std::cout << "Outer x: " << outer::x << std::endl;
std::cout << "Inner y: " << outer::inner::y << std::endl;
std::cout << "Outer x: " << outer::x << '\n';
std::cout << "Inner y: " << outer::inner::y << '\n';
return 0;
}
@ -74,7 +74,7 @@ namespace animals {
int main() {
using animals::dog;
std::cout << "Dog's name: " << dog << std::endl;
std::cout << "Dog's name: " << dog << '\n';
return 0;
}
@ -93,8 +93,8 @@ namespace animals {
int main() {
using namespace animals;
std::cout << "Dog's name: " << dog << std::endl;
std::cout << "Cat's name: " << cat << std::endl;
std::cout << "Dog's name: " << dog << '\n';
std::cout << "Cat's name: " << cat << '\n';
return 0;
}

@ -10,7 +10,7 @@
int globalVar; // This is a global variable
int main() {
std::cout << "Global variable: " << globalVar << std::endl;
std::cout << "Global variable: " << globalVar << '\n';
}
```
@ -22,12 +22,12 @@ int main() {
void localExample() {
int localVar; // This is a local variable
localVar = 5;
std::cout << "Local variable: " << localVar << std::endl;
std::cout << "Local variable: " << localVar << '\n';
}
int main() {
localExample();
// std::cout << localVar << std::endl; //error: localVar was not declared in this scope
// std::cout << localVar << '\n'; //error: localVar was not declared in this scope
}
```
@ -41,7 +41,7 @@ namespace MyNamespace {
}
int main() {
std::cout << "Namespace variable: " << MyNamespace::namespaceVar << std::endl;
std::cout << "Namespace variable: " << MyNamespace::namespaceVar << '\n';
}
```
@ -62,8 +62,8 @@ int MyClass::staticMember = 7;
int main() {
MyClass obj(10);
std::cout << "Static member: " << MyClass::staticMember << std::endl;
std::cout << "Non-static member: " << obj.nonStaticMember << std::endl;
std::cout << "Static member: " << MyClass::staticMember << '\n';
std::cout << "Non-static member: " << obj.nonStaticMember << '\n';
}
```

@ -12,15 +12,15 @@ Example:
#include <iostream>
void print(int i) {
std::cout << "Printing int: " << i << std::endl;
std::cout << "Printing int: " << i << '\n';
}
void print(double d) {
std::cout << "Printing double: " << d << std::endl;
std::cout << "Printing double: " << d << '\n';
}
void print(const char* s) {
std::cout << "Printing string: " << s << std::endl;
std::cout << "Printing string: " << s << '\n';
}
int main() {
@ -44,7 +44,7 @@ Example:
// Template function to print any type
template<typename T>
void print(const T& value) {
std::cout << "Printing value: " << value << std::endl;
std::cout << "Printing value: " << value << '\n';
}
int main() {

@ -12,15 +12,15 @@ Here's an example illustrating function overloading:
#include <iostream>
void print(int num) {
std::cout << "Printing int: " << num << std::endl;
std::cout << "Printing int: " << num << '\n';
}
void print(double num) {
std::cout << "Printing double: " << num << std::endl;
std::cout << "Printing double: " << num << '\n';
}
void print(char const *str) {
std::cout << "Printing string: " << str << std::endl;
std::cout << "Printing string: " << str << '\n';
}
int main() {

@ -53,10 +53,10 @@ int main() {
Rectangle r(4, 6);
Shape* shape = &c;
std::cout << "Circle's area: " << shape->area() << std::endl;
std::cout << "Circle's area: " << shape->area() << '\n';
shape = &r;
std::cout << "Rectangle's area: " << shape->area() << std::endl;
std::cout << "Rectangle's area: " << shape->area() << '\n';
return 0;
}

@ -48,7 +48,7 @@ public:
void display() {
std::cout << "Roll no: " << roll_no
<< "\nName: " << name
<< "\nMarks: " << marks << std::endl;
<< "\nMarks: " << marks << '\n';
}
};

@ -39,11 +39,11 @@ try {
throw "Division by zero not allowed!";
} else {
int result = num1 / num2;
std::cout << "Result: " << result << std::endl;
std::cout << "Result: " << result << '\n';
}
}
catch (const char* e) {
std::cout << "Error: " << e << std::endl;
std::cout << "Error: " << e << '\n';
}
```

@ -31,9 +31,9 @@ int main() {
try {
int result = divide(num1, num2);
std::cout << "The result is: " << result << std::endl;
std::cout << "The result is: " << result << '\n';
} catch (const char* msg) {
std::cerr << "Error: " << msg << std::endl;
std::cerr << "Error: " << msg << '\n';
}
return 0;
@ -71,9 +71,9 @@ int main() {
try {
int result = divide(num1, num2);
std::cout << "The result is: " << result << std::endl;
std::cout << "The result is: " << result << '\n';
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << "Error: " << e.what() << '\n';
}
return 0;

@ -24,12 +24,12 @@ int main() {
// Without auto, iterating the vector would look like this:
for (std::vector<int>::iterator it = myVector.begin(); it != myVector.end(); ++it) {
std::cout << *it << std::endl;
std::cout << *it << '\n';
}
// With auto, the iterator declaration becomes simpler:
for (auto it = myVector.begin(); it != myVector.end(); ++it) {
std::cout << *it << std::endl;
std::cout << *it << '\n';
}
}
```

@ -19,10 +19,10 @@ void modifyVariable(int* ptr) {
int main() {
const int original_value = 10;
int* non_const_value_ptr = const_cast<int*>(&original_value);
std::cout << "Original value: " << original_value << std::endl;
std::cout << "Original value: " << original_value << '\n';
modifyVariable(non_const_value_ptr);
std::cout << "Modified value: " << *non_const_value_ptr << ", original_value: " << original_value << std::endl;
std::cout << "Modified value: " << *non_const_value_ptr << ", original_value: " << original_value << '\n';
assert(non_const_value_ptr == &original_value);

@ -18,7 +18,7 @@ int main() {
for (size_t i = 0; i < sizeof(int); ++i) {
// Print the individual bytes of the integer as characters
std::cout << "Byte " << i << ": " << char_ptr[i] << std::endl;
std::cout << "Byte " << i << ": " << char_ptr[i] << '\n';
}
return 0;

@ -25,7 +25,7 @@ int main() {
MyNamespace::MyClass obj;
obj.value = 42;
using std::cout; // Required to use 'cout' without fully qualifying it.
cout << obj << std::endl; // ADL is used to find the correct overloaded 'operator<<'.
cout << obj << '\n'; // ADL is used to find the correct overloaded 'operator<<'.
}
```

@ -26,7 +26,7 @@ int main() {
int a;
std::cout << "Enter a number: ";
std::cin >> a;
std::cout << "You entered: " << a << std::endl;
std::cout << "You entered: " << a << '\n';
return 0;
}
```

@ -82,7 +82,7 @@ To convert a time point to calendar representation, you can use the `std::chrono
int main() {
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now);
std::cout << "Current time: " << std::ctime(&now_c) << std::endl;
std::cout << "Current time: " << std::ctime(&now_c) << '\n';
return 0;
}
```

@ -32,7 +32,7 @@ You can pass arguments to the thread function by providing them as additional ar
#include <thread>
void print_sum(int a, int b) {
std::cout << "The sum is: " << a + b << std::endl;
std::cout << "The sum is: " << a + b << '\n';
}
int main() {
@ -59,7 +59,7 @@ void print_block(int n, char c) {
for (int i = 0; i < n; ++i) {
std::cout << c;
}
std::cout << std::endl;
std::cout << '\n';
}
}

@ -21,7 +21,7 @@ int main() {
for (int x : vec) {
std::cout << ' ' << x;
}
std::cout << std::endl;
std::cout << '\n';
}
```
@ -44,7 +44,7 @@ int main() {
for (int x : lst) {
std::cout << ' ' << x;
}
std::cout << std::endl;
std::cout << '\n';
}
```
@ -66,7 +66,7 @@ int main() {
std::cout << "Map contains:\n";
for (const auto &pair : m) {
std::cout << pair.first << ": " << pair.second << std::endl;
std::cout << pair.first << ": " << pair.second << '\n';
}
}
```
@ -89,7 +89,7 @@ int main() {
std::cout << "Unordered map contains:\n";
for (const auto &pair : um) {
std::cout << pair.first << ": " << pair.second << std::endl;
std::cout << pair.first << ": " << pair.second << '\n';
}
}
```

@ -33,7 +33,7 @@ T sum(T t, Args... args) {
int main() {
int result = sum(1, 2, 3, 4, 5); // expands to 1 + 2 + 3 + 4 + 5
std::cout << "The sum is: " << result << std::endl;
std::cout << "The sum is: " << result << '\n';
return 0;
}
@ -63,7 +63,7 @@ class Tuple<Head, Tail...> : public Tuple<Tail...> {
int main() {
Tuple<int, float, double> tuple(1, 2.0f, 3.0);
std::cout << "First element: " << tuple.head() << std::endl;
std::cout << "First element: " << tuple.head() << '\n';
return 0;
}
```

@ -36,9 +36,9 @@ int main() {
MyTemplate<double*> t2; // Partial specialization for pointers
MyTemplate<int> t3; // Full specialization for int
std::cout << t1.name() << std::endl;
std::cout << t2.name() << std::endl;
std::cout << t3.name() << std::endl;
std::cout << t1.name() << '\n';
std::cout << t2.name() << '\n';
std::cout << t3.name() << '\n';
return 0;
}

@ -19,12 +19,12 @@ Here is an example:
template <typename T>
void printData(const T& data) {
std::cout << "General template: " << data << std::endl;
std::cout << "General template: " << data << '\n';
}
template <>
void printData(const char* const & data) {
std::cout << "Specialized template for const char*: " << data << std::endl;
std::cout << "Specialized template for const char*: " << data << '\n';
}
int main() {
@ -50,7 +50,7 @@ public:
MyPair(K k, V v) : key(k), value(v) {}
void print() const {
std::cout << "General template: key = " << key << ", value = " << value << std::endl;
std::cout << "General template: key = " << key << ", value = " << value << '\n';
}
private:
@ -65,7 +65,7 @@ public:
void print() const {
std::cout << "Partial specialization for int values: key = " << key
<< ", value = " << value << std::endl;
<< ", value = " << value << '\n';
}
private:

@ -21,8 +21,8 @@ int main() {
int a;
int* a_ptr = &a;
std::cout << "Is 'a' a pointer? " << std::boolalpha << std::is_pointer<decltype(a)>::value << std::endl;
std::cout << "Is 'a_ptr' a pointer? " << std::boolalpha << std::is_pointer<decltype(a_ptr)>::value << std::endl;
std::cout << "Is 'a' a pointer? " << std::boolalpha << std::is_pointer<decltype(a)>::value << '\n';
std::cout << "Is 'a_ptr' a pointer? " << std::boolalpha << std::is_pointer<decltype(a_ptr)>::value << '\n';
return 0;
}
@ -46,7 +46,7 @@ typename std::enable_if<std::is_arithmetic<T>::value, T>::type find_max(T a, T b
int main() {
int max = find_max(10, 20);
std::cout << "Max: " << max << std::endl;
std::cout << "Max: " << max << '\n';
return 0;
}

@ -13,7 +13,7 @@ The C++11 standard, also known as C++0x, was officially released in September 20
```cpp
std::vector<int> numbers {1, 2, 3, 4};
for (int number : numbers) {
std::cout << number << std::endl;
std::cout << number << '\n';
}
```

@ -57,7 +57,7 @@ std::future<int> async_value(int value) {
int main() {
auto result = async_value(42);
std::cout << "Result: " << result.get() << std::endl;
std::cout << "Result: " << result.get() << '\n';
}
```

@ -16,7 +16,7 @@ Some of the notable features in C++11 include:
```cpp
std::vector<int> vec = {1, 2, 3};
for (int i : vec) {
std::cout << i << std::endl;
std::cout << i << '\n';
}
```

@ -15,7 +15,7 @@ Here's a brief summary of the different C++ standards released to date:
```cpp
std::vector<int> numbers = {1, 2, 3, 4};
for (int num : numbers) {
std::cout << num << std::endl;
std::cout << num << '\n';
}
```
- Smart pointers like `std::shared_ptr` and `std::unique_ptr`.

@ -51,7 +51,7 @@ int main() {
int num2 = 0;
int result = num1 / num2;
std::cout << "Result: " << result << std::endl;
std::cout << "Result: " << result << '\n';
return 0;
}

@ -38,7 +38,7 @@ Suppose you have a simple `cpp` file called `example.cpp`:
#include <iostream>
void my_function(int i) {
std::cout << "In my_function with i = " << i << std::endl;
std::cout << "In my_function with i = " << i << '\n';
}
int main() {

@ -13,7 +13,7 @@ The first stage is the preprocessing of the source code. Preprocessors modify th
#define PI 3.14
int main() {
std::cout << "The value of PI is: " << PI << std::endl;
std::cout << "The value of PI is: " << PI << '\n';
return 0;
}
```

@ -15,19 +15,19 @@ To use the PyTorch C++ API, you need to install the LibTorch distribution. Follo
int main() {
// Create a 3x3 matrix with zeros.
torch::Tensor a = torch::zeros({3, 3});
std::cout << a << std::endl;
std::cout << a << '\n';
// Create a 2x2 matrix with ones and convert to float.
torch::Tensor b = torch::ones({2, 2}).to(torch::kFloat);
std::cout << b << std::endl;
std::cout << b << '\n';
// Create a random tensor size 2x2 and specify its type.
torch::Tensor c = torch::randint(0, 10, {2, 2}, torch::kInt);
std::cout << c << std::endl;
std::cout << c << '\n';
// Perform element-wise addition.
auto sum = b + c.to(torch::kFloat);
std::cout << sum << std::endl;
std::cout << sum << '\n';
}
```
@ -62,7 +62,7 @@ int main() {
// Use the custom module.
torch::Tensor input = torch::randn({2, 1, 28, 28});
torch::Tensor output = net.forward(input);
std::cout << output << std::endl;
std::cout << output << '\n';
return 0;
}

@ -51,17 +51,17 @@ int main()
std::string responseBody;
StreamCopier::copyToString(responseStream, responseBody);
std::cout << "Response: " << responseBody << std::endl;
std::cout << "Response: " << responseBody << '\n';
}
else
{
// Error
std::cout << "Error: " << response.getStatus() << " " << response.getReason() << std::endl;
std::cout << "Error: " << response.getStatus() << " " << response.getReason() << '\n';
}
}
catch(const Exception& e)
{
std::cerr << "Error: " << e.displayText() << std::endl;
std::cerr << "Error: " << e.displayText() << '\n';
return -1;
}

@ -58,9 +58,9 @@ Here is a brief summary of protobuf and how to use it in C++:
input.close();
// Print the deserialized message
std::cout << "Name: " << input_person.name() << std::endl;
std::cout << "Age: " << input_person.age() << std::endl;
std::cout << "Email: " << input_person.email() << std::endl;
std::cout << "Name: " << input_person.name() << '\n';
std::cout << "Age: " << input_person.age() << '\n';
std::cout << "Email: " << input_person.email() << '\n';
google::protobuf::ShutdownProtobufLibrary();

@ -66,7 +66,7 @@ void RunServer() {
builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl;
std::cout << "Server listening on " << server_address << '\n';
server->Wait();
}
@ -120,7 +120,7 @@ int main(int argc, char** argv) {
GreeterClient greeter(grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials()));
std::string user("world");
std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl;
std::cout << "Greeter received: " << reply << '\n';
return 0;
}

@ -50,7 +50,7 @@ int main() {
// Output results
for (size_t i = 0; i < A.size(); ++i) {
std::cout << A[i] << " + " << B[i] << " = " << C[i] << std::endl;
std::cout << A[i] << " + " << B[i] << " = " << C[i] << '\n';
}
return 0;
}

Loading…
Cancel
Save