Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2010, 12:39
Fecha de Ingreso: octubre-2010
Mensajes: 3
Antigüedad: 13 años, 5 meses
Puntos: 0
how could I obtain the same result like with StringTokenizer in Java [strtok in C++]


I want to create an application in C++ where the user pass by argument 3 parameters as the next: p:port h:host m:message

so, i wan't to get this arguments and identificate it.
in Java I know how do this, with StringTokenizer, but in C++ not.
I know that exists a method called "strtok" (<string.h>) that could be use in order to do this.

The problem is that I have not idea of C++. Could you help me with the problem??

The equivalent in Java will be:

String prefix = null;
String sufix = null;
StringTokenizer t = null;

for (int i=0; i<args.length; i++)
t = new StringTokenizer (args[i], ":");
prefix = t.nextToken();
sufix = t.nextToken();


I want to do the same but in c++.