Generate a list of certain length Passwords.

I want to generate a list of passwords of a cretain length passwords from a packet FILE. The packet file means a .txt FILE which contains more than 1M passwords of certain lengths. I want to store password of DIFFERENT length in a various .txt FILES

Your method is inefficient. Suppose len1 equals 5 and len2 equals 15. I have an input file containing a million words and my goal is to create 10 files ("5-length-pass.txt", "6-length-pass.txt", ..., "14-length-pass.txt"). You are trying to read the in the entire input file 10 times. That's inefficient. How about, instead, creating an array of 10 ofstreams from the start? Read the file once. As each input word is read once, check the length and output it to the correct ofstream, like so.