String teilen
-
hallo,
ich hab unter windows in C ein prog geschieben, in dem strings folgender art vorkommen:XFR 3 NS 207.46.6.88:1863 0 65.54.239.80:1863
ich muss den string so teilen, dass ich nur mehr die erste ip habe, also ich muss irgendwie 207.46.6.88 extrahieren
die ip ist natürlich immer ne andere, beginnt aber immer mit 207., falls das ne hilfe ist.
strtok hab ich schon probiert, geht aber net.
irgendwas wo ich das in der form von fscanf einlesen könnte wäre gut *denk
danke für jede hilfe
lg papanoah
-
sscanf, scannt aus nem string raus.
sscanf(deinstring, "%*s %*s %*s %s", ipstring);Following the percent character (%) in the format string, you can write an asterisk (*) to indicate that the conversion should not store the converted value in an object.
http://www-ccs.ucsd.edu/c/lib_scan.html#Scan Functions
http://www.cppreference.com/stdio/sscanf.html
-
ah, das is gut, danke!
lg papanoah