Mailinglist Archive: opensuse (4053 mails)

< Previous Next >
[SLE] splitting a string
  • From: Jesse Marlin <jesse.marlin@xxxxxxxxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 9 Aug 2001 09:18:35 -0400
  • Message-id: <15218.36267.506761.8824@xxxxxxxxxxxxxxxx>
S.Toms writes:
> Quick question for everyone, I want to beable to split a string that
> contains a colon at the colon, for example
>
> 4.23.242.12:2323

In C or C++:

char ip[50];
int port;

cnt = sscanf (buf, "%[^:]:%s", ip, &port);



>
> I'd like to remove the colon and whatever follows it. Unfortunately, I
> havn't figured out a way to do it with what I know.
>
> --
> S.Toms - smotrs@xxxxxxxxxxxxxx - www.mindspring.com/~smotrs
> SuSE Linux v7.0+ - Kernel 2.2.18
>
> Silverman's Law:
> If Murphy's Law can go wrong, it will.
>
>
> --
> To unsubscribe send e-mail to suse-linux-e-unsubscribe@xxxxxxxx
> For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
> Also check the FAQ at http://www.suse.com/support/faq and the
> archives at http://lists.suse.com


< Previous Next >
References