To limit the length of input with getline, you can use the substr function to extract a portion of the input string after reading it. For example, you can read the input using getline and then use input = input.substr(0, max_length); to limit the input to a maximum number of characters.