Finding consecutive numbers in a vector
First use ++it instead it++ with iterators.
You can replace this loop:

for (vector&lt;int&gt;::const_iterator itr = vec.begin();
     itr != vec.end() + 1; itr++)`


with range-based for:

for (auto i : v)

vec.end() returns iterator representing element after the last element in vector
if (itr != vec.end()) loop also does this check
I think you can rewrite your code to be clearer and with less ifs
also you can use std::to_string instead of intToString
also if you want to append . at the end of string you can do it outside of the loop




Here is the code with few things fixed; still I think you can do even better than that if you rethink your conditions.

void createLines(vector&lt;int&gt;&amp; vec, string&amp; line)
{
  int start = *vec.begin(), end = -1, offset = 0; // initial offset to start

  for (auto i : vec)
  {
    if (i == start + offset)
    {
      end = i;
      ++offset;
    } // check if line numbers are consecutive and not reading at end of vector
    else // not consecutive
    {
      if ((end != -1) &amp;&amp; (end != start))
      {
        line.append(to_string(start) + "-");
        line.append(to_string(end));
      } // if there existed consecutive numbers, display with dash
        // must be difference of at least 1
      else // else, there were no consecutive numbers
        line.append(to_string(start));

    line.append(", ");

  start = i; // set start to next line number. Soft reset.
  offset = 1; // change default offset to 1. 0 for first case.
  end = -1;
} // not consecutive
} // Get all line numbers and format for proper output
 if ((end != -1) &amp;&amp; (end != start))
 {
   line.append(to_string(start) + "-");
   line.append(to_string(end));
 } 
 else
   line.append(to_string(start));
line.append(".");
} // createLines()