convert a string xxx.xxx.xxx.xxx in a number (CIDR format)
Franco Amato
eurofrank at gmail.com
Mon May 7 08:52:53 PDT 2007
What does exactly the format
"%3d%*[.]%3d%*[.]%3d%*[.]%3d",
do?
Frank
2007/5/7, Franco Amato <eurofrank at gmail.com>:
>
> Thank very much to all.
> You have been very clean.
> For sergio Barbosa...VB is for?? (Visual Basic?? ahah)
> Frank
>
>
> 2007/5/6, Mohd Radzi Ibrahim <mradzi at pc.jaring.my>:
> >
> > In wxWidget, you can use wxStringTokenizer.
> >
> > wxStringTokenizer tk(wxT("255.255.255.0",wxT("."));
> > long address[4];
> > int i=3D0;
> > while (tk.HasMoreTokens())
> > {
> > wxString s =3D tk.GetNextToken();
> > s.ToLong(&address[++i]);
> > }
> >
> >
> > best regards,
> > Radzi.
> >
> > ----- Original Message -----
> > *From:* Franco Amato <eurofrank at gmail.com>
> > *To:* wx-users at lists.wxwidgets.org
> > *Sent:* Saturday, May 05, 2007 9:04 AM
> > *Subject:* Re: convert a string xxx.xxx.xxx.xxx in a number (CIDR
> > format)
> >
> >
> > Thank to all.
> > To extract every field from the full entiere strind (xxx.xxx.xxx.xxx -
> > every fiels is a single xxx)
> > I used the strtok()...is there an analogue function in c++?
> > Regards
> > Frank
> >
> >
> > 2007/5/4, Carsten A. Arnholm <arnholm at offline.no>:
> > >
> > >
> > > Friday, May 4, 2007, 2:07:18 PM, you wrote:
> > > > Hi people, sorry in advance for the off-topic question.
> > > > I have to convert a string in the format 255.255.255.0 in a number
> > > > (in this example 30).
> > > > code in C standard....
> > > > to convert a single octet (255 =3D 7, int to int) is not a problem,
> > > the
> > > > problem is convert a string.
> > > > For example if I have char vett[3] where vett[0]=3D2 vett[1]=3D5 and
> > > > vett[2]=3D5, how can I convert it in a int with the value 255???
> > > > Thank you
> > > > Franco
> > >
> > > Hi Franco,
> > >
> > > In C++ I would maybe do
> > >
> > > #include <sstream>
> > > #include <iostream>
> > > using namespace std;
> > > int main()
> > > {
> > > char vett[] =3D "255";
> > > int ivalue =3D 0;
> > > istringstream in(vett);
> > > in >> ivalue;
> > > cout << ivalue << endl;
> > > return 0;
> > > }
> > >
> > > In plain C you could possibly use the atoi function
> > >
> > > int i;
> > > i =3D atoi(vett );
> > >
> > > --
> > > Carsten A. Arnholm
> > > http://arnholm.org/
> > > N59.776 E10.457
> > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> > > For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
> > >
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070507/402=
09c54/attachment.htm
More information about the wx-users
mailing list