Possible Duplicate:
Splitting a string in C++
I am doing client server programming using C++.
My client sends a string with the value
string receiveClient = "auth#user:pass";
How do I split the receiveClient
variable by '#'
and ':'
as delimiters?
I have tried to use this function I found online
vector split (const string &s,char delim)
{
vector string elems;
return(s,delim,elems);
}
and I did this at main()
:
vector x = split(&receiveClient,"#");
But it return me the following
server.cpp: In function ‘int main()’:
server.cpp:128:8: error: missing template arguments before ‘x’
server.cpp:128:8: error: expected ‘;’ before ‘x’
root@ubuntu:/home/baoky/csci222_assn2# g++ server server.cpp
server.cpp:47:1: error: invalid use of template-name ‘std::vector’ without an argument list
server.cpp: In function ‘int main()’:
server.cpp:128:8: error: missing template arguments before ‘x’
server.cpp:128:8: error: expected ‘;’ before ‘x’
Thanks for all help. greatly appreciated