Вы можете сделать это с помощью strtol
, например:
char *str = "ab234cid*(s349*(20kd", *p = str;
while (*p) { // While there are more characters to process...
if ( isdigit(*p) || ( (*p=='-'||*p=='+') && isdigit(*(p+1)) ) {
// Found a number
long val = strtol(p, &p, 10); // Read number
printf("%ld\n", val); // and print it.
} else {
// Otherwise, move on to the next character.
p++;
}
}
Ссылка на ideone .
В Быстром 4/5 используйте "firstIndex" для индекса находки.
let index = array.firstIndex{[110] == value}
в Swift 4.2
.index (где:) был изменен на .firstIndex (где:)
array.firstIndex(where: {[110] == "person1"})