Is there a function in c++ that does the same that the split function in C?
I wrote this code
std::string str[] =line.split(";");
But a call to split is not recognized.
Is there a function in c++ that does the same that the split function in C?
I wrote this code
std::string str[] =line.split(";");
But a call to split is not recognized.
Looks like you need qt
solution :
#include <QStringList>
//...
QStringList L = line.split( ";" , QString::SkipEmptyParts );
// ^^^^^^^^^^^^^^optional
Yes, there is a split function. See: http://qt-project.org/doc/qt-4.8/qstring.html#split as reference.
There is no such a standard function in C++. You can use the following approach.
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
//,,,
std::istringstream is( line );
std::vector<std::string> v;
std::string item;
while ( std::getline( is, item, ';' ) ) v.push_back( item );