Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Need help in Java char[]...

Name: Anonymous 2007-04-28 19:19 ID:r3l/lAht

Okay guys... I have a char[] suposely made of A's, B's and C's...

If I find a character that isn't one of those, I want it to throw an exception and leave.

how do I do it?

char[] zong = {A,L,C,B,}

for (int k = 0; k < zong.length; k++ ) {
if ((zong[k] != A) && (zong[k] != B) && (zong[k] != C)) {
throw new Exception("exit");
}
}

Is this it?

thanks, /prog/

Name: Anonymous 2007-04-28 20:22 ID:sO3981t4

Holy shit people, it's called strpbrk.

char *pos = strpbrk(zong, "ABC");
After the call to strpbrk, *pos will be either '\0' (good, the entire string was A's, B's, and C's) or the first character in the string that wasn't one of those characters.

If Java doesn't have anything even remotely similar to this, Java is a shitty fucking language and deserves immediate death.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List