Возможный дубликат:
Как разбить строку на С++?
Мне нужно разбить строку на отдельные пробелы и сохранить ее в массив строк. Я могу достичь этого, используя istringstream, но то, чего я не могу достичь, следующее:
Я хочу, чтобы каждое пространство прерывало текущее слово. Итак, если есть два пробела подряд, один элемент моего массива должен быть пустым.
Например:
(подчеркивание обозначает пробел)
This_is_a_string.
gets split into:
A[0] = This
A[1] = is
A[2] = a
A[3] = string.
This__is_a_string.
gets split into:
A[0] = This
A[1] = ""
A[2] = is
A[3] = a
A[4] = string.
Как это реализовать?