lstlisting environment (whether used directly or via
\lstinputlisting) together with the
float specifier does not break across pages. The
float key boxes the entire listing into a single unit or block that allows it to float. It does not break the listing into separate floats the with move as a sequential unit. This is similar to the restriction imposed by the
minipage environment. Even though the
listings package documentation mentions breaking (and a host of breaking options), they all refer to line breaking, but not page breaking.
So, in order for the listing to break across pages, you could remove the
float=<specifier> key-value. However, this does not accommodate an automatic (continued) caption for subsequent page-broken listings. This may not be that important (or as big-a-deal) if the listing spans only two pages, since a reader would easily be able to follow the broken listing. However, a listing spanning multiple pages might not be such a good idea.
Alternatively, if you want you could manually break the listing into (at least) two blocks so that neither block is larger than a single page. For this you can use a combination of the
% First part of listing
% Second part of listing
<x> is the last line of the first part of the
<x+1> the first line of the second part of the
lstlisting. If you are using line numbers in your listing, you may need to specify the line number for the second part, as this may default to starting from
1. Hence, the addition of
firstnumber=<x+1> as part of the
lstlisting key-value sequence. You may also be required to modify the listing caption and specify that the listing continues from some previous one rather than having a number that does not match the former. If your listing has to be split across more than two pages, the same configuration as above holds, with the use of
linerange=<first>-<last>,firstnumber=<first> for the middle listings.
There is no need to place the
lstinputlisting environment in a float (like
figure), since it the package provides it's own form of floating listing (via the key-value
Lastly, an alternative that should work but is not easy to accomplish, is to actually shorten your code so that the listing can fit on a single page.
On a side-note, wrapping the
center environment around a floating environment (like
figure) won't help you either and cause problems. In any case, the outer-most environment should be the float (
figure, or...), with the formatting environments contained within.