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

Pages: 1-

What's a good name for...

Name: Anonymous 2012-06-04 11:08

A function that's like strchr or strrchr, but finds either the first or last character of a string that is NOT equal to the given character?

Name: Anonymous 2012-06-04 12:04

Name: Anonymous 2012-06-04 20:12

>>2
No, that finds the first character equal to a character in a string. I want to find the first character not equal to a character in a string.

Name: Anonymous 2012-06-04 20:21

The evil twin of strspn is strcspn, so strcchr.

Name: Anonymous 2012-06-04 20:28

>>1
They'd probably be called strcchr and strrcchr. I think strspn with a single-character string does what you want.

Name: Anonymous 2012-06-04 20:54

find_first_or_last_char_not_equal_to(char this_char);

Name: Anonymous 2012-06-04 21:18

ENTERPRISE QUALITY
FindFirstOrLastCharNotEqualToFactory findFirstOrLastCharNotEqualToFactory = new FindFirstOrLastCharNotEqualToFactory(aChar);
FindFirstOrLastCharNotEqualTo findFirstOrLastCharNotEqualTo = findFirstOrLastCharNotEqualToFactory.makeFindFirstOrLastCharNotEqualTo(aString);
try {
     System.out.println("First not equal char: " + firstOrLastCharNotEqualTo.getFirstCharNotEqualTo());
     System.out.println("Last not equal char: " + firstOrLastCharNotEqualTo.getLastCharNotEqualTo());
} catch (AllCharsEqualException e) {
     System.err.println("AllCharsEqualException: All of the characters are equal.");
     throw new EnterAnotherStringException(e);
}

Name: Anonymous 2012-06-04 22:27

>>7
try/catch for local error handling

rustled

Name: Anonymous 2012-06-05 3:39

>>8
rustled
/polecat kebabs/

Name: Anonymous 2012-06-05 7:55

>>4,5
No, strspn doesn't do what I want, even if I switch the arguments around--it's based on equality. Nor does strcspn do it either, it just returns an offset instead of a pointer.

I'm going to name them as strxchr, strnxchr, strrxchr, strnrxchr, etc.

Name: Anonymous 2012-06-05 8:03

Why not just search_pattern(char *s, bool (*foo)(char)) ?

Name: Anonymous 2012-06-05 8:11

>>10
Actually, never mind, the shitty documentation I was looking at had the same description for strspn and strcspn. I'm now going to call them strcchr, etc.

Name: >>4 2012-06-05 8:26

>>10,12
That was what I was trying to tell you.

Name: CHRIS TOREK THE PANDA 2012-06-05 8:47

>The following names are grouped under individual headers for convenience.
>All external names described below are reserved no matter what headers are included by the program.

...

7.31.12 General utilities <stdlib.h>
Function names that begin with str and a lowercase letter may be added to the declarations in the <stdlib.h> header.


>7.31.13 String handling <string.h>
Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header.


HAHAHAH THE STANDARD WINS AGAIN!
*DANCES AROUND IN CIRCLES WITH RICHARD STALLMAN AND THE SUSSMAN*

Name: Anonymous 2012-06-05 10:45

>>11
That's functionally good enough, but performance wise, I need something without additional call overhead per character. Doing some large scale data file processing and symbol parsing. It's not hard to roll your own strchr style functions, I just needed a good name for them.

Example:

char const* strncchr(char const* s, int c, size_t n) noexcept {
    assert(s || !n);
       
    for ( ; n > 0; ++s, --n) {
        if (*s != c) {
            return s;
        }
    }
       
    return nullptr;
}

Name: Anonymous 2012-06-05 10:45

>>14
He's just making his library so that including it is mutually exclusive with including stdlib and string, nobody uses those anyway.

Name: Anonymous 2012-06-05 10:50

>>14
I'm programming in C++11, and I have added these functions into my own namespace. The fully qualified names are ::<my namespace>::strcchr, etc. Thus, they do not conflict with the Standard C library reserved names.

Despite C++ sucking a lot, this is one of those cases where C++ clearly wins!.

Name: 14 2012-06-05 19:36

>>17
Rats! Foiled again.

Name: Anonymous 2012-06-05 19:37

>>18 fuck you bitch i m gonna kill u1!!

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