Kwalifikacja: INF.04 - Projektowanie, programowanie i testowanie aplikacji

Kategorie: Programowanie Projektowanie aplikacji

Przedstawiony fragment dotyczy funkcji resize w języku C++. Ta funkcja obniży długość elementu string, gdy wartość parametru

Resize string
Resizes the string to a length of n characters.

If n is smaller than the current string length, the current value is shortened to its first n character, removing the characters beyond the nth.

If n is greater than the current string length, the current content is extended by inserting at the end as many characters as needed to reach a size of n. If c is specified, the new elements are initialized as copies of c; otherwise, they are value-initialized characters (null characters).

Parameters
n
New string length, expressed in number of characters.
size_t is an unsigned integral type (the same as member type string::size_type).
c
Character used to fill the new character space added to the string (in case the string is expanded).
Źródło: http://www.cplusplus.com/reference/string/string/resize/

Odpowiedzi