string - Get substring before a certain char in (c) -
for example, have string: 10.10.10.10/16
and want remove mask ip , get: 10.10.10.10
how done?
just set 0 @ place of slash
#include <string.h> /* strchr() */ char address[] = "10.10.10.10/10"; char *p = strchr(address, '/'); if (!p) /* deal error: / not present" */; *p = 0;
i don't know if works in c++
c string char
No comments:
Post a Comment