Дано
Код: Выделить всё
std::vector data {
"jpg yuvj420p 1080x2400 1:1 9:20",
"jpeg yuvj420p 1536x2048 72:72 3:4",
"jpg yuvj444p 1920x1080 1:1 16:9",
"png rgba 150x150 NA NA",
/* ... up to 35 (56?) more, all of which start *
* with one of the strings in extensions */
};
std::vector extensions {
"png", "jpg", "jpeg", // ... 2 to 4 more
};
std::ofstream file ("data.txt");
Код: Выделить всё
for (auto& ext : extensions)
{
for (auto& it : data)
if (it.starts_with(ext)
file
Подробнее здесь: [url]https://stackoverflow.com/questions/79091737/which-approach-is-cheaper-when-iterating-through-a-vector-to-sort-it-based-on-a[/url]
Мобильная версия