You don't need an extra loop to track the maximum; you can just do that "on the fly" in the outermost loop (for) in main().

A short breakdown on how to do it: Declare a variable for the maximum before entering the loop, and initialize it to an impossibly low maximum value. 0 would be a natural choice for that. During each of the iterations, check whether the current sequence length is greater than the maximum you have so far, and if yes, adjust the maximum accordingly. Once you're done with the loop, you have your maximum.

The C++ code required to do this, BTW, would be much less characters than my description above.

HTH