1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace std;
const char *getTok(const char str[],const int pos,const char asc) {
istringstream iss(str);
string mot;
for(int i=1;i<=pos;i++) { getline(iss,mot,asc); }
size_t size = mot.size() + 1;
char * buffer = new char[size];
strncpy_s(buffer,size,mot.c_str(),size);
return buffer;
}
int main() {
char hu[] = "200.;0;.0.;90-200;.0.0.2;23";
cout<<hu<<endl<<endl
<<"getTok(hu,5,';')"<<" -> "<<getTok(hu,5,';')<<endl;
system("PAUSE");
return 0;
} |
Partager