владисл В владисл Регистрация 4 Дек 2013 Сообщения 95 Репутация 0 Спасибо 0 Монет 0 8 Авг 2024 #1 void split(char* lst[], string str, string separator = " ") { stringstream strr(str); char* word; int i = 0; int size = sizeof(lst); while (strr >> word) { if (i > size) { break; } cout
void split(char* lst[], string str, string separator = " ") { stringstream strr(str); char* word; int i = 0; int size = sizeof(lst); while (strr >> word) { if (i > size) { break; } cout
ччч Ч ччч Регистрация 24 Ноя 2013 Сообщения 89 Репутация 0 Спасибо 0 Монет 0 8 Авг 2024 #2 char* word; - объявлен указатель, память не выделена ... while (strr >> word) - считываем что-то в никуда если ты уже используешь std::string, забудь ты про char*, используй тот же std::string
char* word; - объявлен указатель, память не выделена ... while (strr >> word) - считываем что-то в никуда если ты уже используешь std::string, забудь ты про char*, используй тот же std::string
Коламан К Коламан Регистрация 24 Сен 2013 Сообщения 91 Репутация 0 Спасибо 0 Монет 0 8 Авг 2024 #3 #include #include #include #include #include using namespace std; vector split(const string& line) { stringstream ss(line); list lst; string word; while (ss >> word) lst.push_back(word); vector words(lst.size()); copy(lst.begin(), lst.end(), words.begin()); return words; } string input_string(const char* prompt) { cout
#include #include #include #include #include using namespace std; vector split(const string& line) { stringstream ss(line); list lst; string word; while (ss >> word) lst.push_back(word); vector words(lst.size()); copy(lst.begin(), lst.end(), words.begin()); return words; } string input_string(const char* prompt) { cout
zekabk Z zekabk Регистрация 27 Окт 2013 Сообщения 92 Репутация -3 Спасибо 0 Монет 0 8 Авг 2024 #4 #include #include #include #include void split(std::vector& lst, const std::string& str, const std::string& separator = " ") { std::stringstream strr(str); std::string word; while (std::getline(strr, word, separator[0])) { lst.push_back(word); } } int main() { std::vector words; std::string text = "This is a test string"; std::string sep = " "; split(words, text, sep); for (const auto& word : words) { std::cout
#include #include #include #include void split(std::vector& lst, const std::string& str, const std::string& separator = " ") { std::stringstream strr(str); std::string word; while (std::getline(strr, word, separator[0])) { lst.push_back(word); } } int main() { std::vector words; std::string text = "This is a test string"; std::string sep = " "; split(words, text, sep); for (const auto& word : words) { std::cout
Михаил4635 М Михаил4635 Регистрация 30 Сен 2013 Сообщения 85 Репутация 0 Спасибо 0 Монет 0 8 Авг 2024 #5 В предоставленном куске я вижу ошибку int size = sizeof(lst); Которая не "посчитает" размера массива
В предоставленном куске я вижу ошибку int size = sizeof(lst); Которая не "посчитает" размера массива