diff options
| author | Carlos Maiolino <[email protected]> | 2025-09-06 09:37:14 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-09-06 09:37:14 +0200 |
| commit | 2c9056a23e1a55fd21a8e314c903d9325bffd62e (patch) | |
| tree | a73ba1c7bb60dd89c9e70769dd510e59a49a56a1 /CPP/cpp_book/test.cpp | |
| parent | ee8a08bfa24d9a3d09273fdebe8d73ac38c545f9 (diff) | |
Move CPP code here
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'CPP/cpp_book/test.cpp')
| -rw-r--r-- | CPP/cpp_book/test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
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 <iostream> +#include <string> + +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; +} |
