From 2c9056a23e1a55fd21a8e314c903d9325bffd62e Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sat, 6 Sep 2025 09:37:14 +0200 Subject: Move CPP code here Signed-off-by: Carlos Maiolino --- CPP/cpp_book/test.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 CPP/cpp_book/test.cpp (limited to 'CPP/cpp_book/test.cpp') diff --git a/CPP/cpp_book/test.cpp b/CPP/cpp_book/test.cpp new file mode 100644 index 0000000..28186d3 --- /dev/null +++ b/CPP/cpp_book/test.cpp @@ -0,0 +1,39 @@ +#include +#include + +struct name { + std::string name; + int num[5]; +}; + +int main(void) { + + int x; + int i = 0; + struct name foo; + struct name bar; + std::cin >> foo.name; + while (std::cin >> x) { + foo.num[i] = x; + i++; + + if (i >= 5) + break; + } + i = 0; + + if (std::cin) + std::cout << "We have data" << std::endl; + std::cin.clear(); + std::cin >> bar.name; + while (std::cin >> x) { + bar.num[i] = x; + i++; + + if (i >= 5) + break; + } + + std::cout << foo.name.size() << " " << bar.name.size() << std::endl; + return 0; +} -- cgit v1.2.3