From 27d0bbca0b4c0c9d3aeebdac6a8274d71b6d9e38 Mon Sep 17 00:00:00 2001 From: Yue Wang Date: Sat, 29 Nov 2014 19:44:33 +1300 Subject: [PATCH] fix Unicode semicolon bug --- ch12/ex12.26.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ch12/ex12.26.cpp b/ch12/ex12.26.cpp index a8213558..18a445f8 100644 --- a/ch12/ex12.26.cpp +++ b/ch12/ex12.26.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * @file The code is for the exercises in C++ Primmer 5th Edition - * @author Alan.W - * @date 26 DEC 2013 + * @author @Yue Wang @gupenghu + * @date 29.11.2014 * @remark ***************************************************************************/ @@ -21,27 +21,32 @@ int main() std::string* p_movable = p; //! constuct each object using copy constructor - std::string word; - while(std::cin >> word && p_movable != p + 3) - { + std::cout << "enter 4 times\n"; + for(std::string word ;std::cin >> word && p_movable != p + 3; ++p_movable) alloc.construct(p_movable,word); - ++p_movable; - } //! move the movable pointer back home p_movable = p; //! print the strings constructed. - while(p_movable != p + 3){ + for( ; p_movable != p + 3; ++p_movable){ std::cout << *p_movable <<"\n"; alloc.destroy(p_movable); - ++p_movableļ¼› } //! free the allocated memory. alloc.deallocate(p, 5); - - - + std::cout << "exit normally\n"; return 0; } +//! output +//! +//enter 4 times +//ss +//ss +//ss +//ss +//ss +//ss +//ss +//exit normally