kekanaka / elements-of-programming-interviews

Automatically exported from code.google.com/p/elements-of-programming-interviews
Other
0 stars 0 forks source link

10.2 Indirect Sort Output Error #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a text file with string input of variable lengths
2. Run the book solution for 10.2 (pg 288) over the input file

What is the expected output? What do you see instead?
Expected to see sorted strings in output file, instead I see memory addresses.

What version of the product are you using? On what operating system?
1.1.5, Windows 7

Please provide any additional information below.

the lines
for (const T* p : P) {
     ofs << p << endl;
}

shouldn't it be the de-referenced pointer
" ofs << *p << endl; "

otherwise we write out the pointer addresses to file.

Original issue reported on code.google.com by aajtodd on 20 Jul 2013 at 3:45

GoogleCodeExporter commented 8 years ago
Hey Arron,

Thanks for your reporting, this bug is fixed before and the updated solution is 
at 
https://code.google.com/p/elements-of-programming-interviews/source/browse/trunk
/indirect_sort.cpp. Please take a look of that.

If you have any problem or question about your career advice, please write 
email to me (tsung.hsien.lee@gmail.com) or Dr. Adnan Aziz 
(adnan.aziz@gmail.com) or Dr. Amit Prakash (amit.prakash@gmail.com). We really 
enjoy our readers to contact with us :)

Original comment by TsungHsi...@gmail.com on 20 Jul 2013 at 5:49