David W's Profile
Reputation: 275 Architect
- Active Posts:
- 1,781 (0.84 per day)
- 20-September 08
- Profile Views:
- Last Active:
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Dream Kudos:
01 Jul 2014 - 07:02
22 Jun 2014 - 17:38
15 Jun 2014 - 16:35
15 Jun 2014 - 16:16
15 Jun 2014 - 10:44
13 Jan 2014 - 12:15
05 Jan 2014 - 04:01
16 Nov 2013 - 10:15
07 Oct 2013 - 11:40
29 Sep 2013 - 21:15
Posts I've Made
Posted 15 Jun 2014Merging two pre-sorted files is more intricate than merging two pre-sorted arrays.
If you do a search on the web you may find some (file) examples to guide you.
Try Google of keywords like: merge two sorted files
I think there is at least one simple example here at DIC also.
I found this that looks ok but not as simple as it could be ...
example of merge sorted files
Do not forget to handle all the cases ... including the case of either file being empty. (You may assume both files are pre-validated to contain valid pre-sorted data.)
Posted 15 Jun 2014I was thinking that since stol was used in the OP then it was available and so C++11 is within the scope of this thread.
My demo's were meant mainly ... (as I believe were also Jim's main thrust ... ) to indicate *the ease of parsing a line of test using (mostly) stringstream*
Posted 15 Jun 2014
QuoteSecondly many students will use these features blindly, and will be totally lost when their programs don't properly compile for their instructors because the instructor doesn't use a C++11 compiler. Using these new features wisely is the key.
So students ... if your prof's are checking your code with pre-C++ 11 compilers ...
please be advised ...
if you play with the new C++ 11 features ...
it's probably best to only submit code that compiles ok with a pre-C++ 11 compiler
Posted 15 Jun 2014But Jim,
you can not logically ... at the same time ...
promote the use of C++ compilers (before C++ 11) to keep things readily compiled by students who still use pre C++11
and then offer C+11 as a rebuttal
(as per your statements that C++ 11 allows files to be opened with C++ string ... and using the other functions specific to C++ 11)
Your other arguments are understood, but I think ...
'no big deal' ...
in this specific example.
Posted 15 Jun 2014Hi Jim,
I think you missed my point ... (about using stringstream every-where ... and then using the below special handling for the date string only.)
C strings are not always 'crappy'
Please note that C++ file handling still needs a C string (or text) to be passed in to open a file.
Here ... the code, using a C string buf is 'easy' and 'clear' and 'simple' ... (and more logical-perhaps?)
So ... no need then, to disparage the use of C string and atoi to handle that special case.
- Member Title:
- DIC supporter
- 67 years old
- June 29, 1947
- Toronto Ontario Canada
- The events that lead up to the soon return of Yeshua (Jesus) ... and being ready
- Full Name:
- David Wayne Zavitz
- Programming Languages:
HLA (High Level Assembly)
- Click here to e-mail me
- Website URL: