diff options
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; +} |
