Skip to content

Commit

Permalink
Update ex12_26.cpp
Browse files Browse the repository at this point in the history
Exchange the order of the  bool evaluation because there is no need to ask input if pointer q reached the end of the dynamic memory.
  • Loading branch information
boscotsang committed Apr 14, 2016
1 parent 32357c6 commit dca4fd0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ch12/ex12_26.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void input_reverse_output_string(int n)
auto const p = alloc.allocate(n);
std::string s;
auto q = p;
while (std::cin >> s && q != p + n)
while (q != p + n && std::cin >> s)
alloc.construct(q++, s);

while (q != p)
Expand Down

0 comments on commit dca4fd0

Please sign in to comment.