[ create a new paste ] login | about

Link: http://codepad.org/MuOKmHox    [ raw code | output | fork ]

C, pasted on Dec 26:
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
int main(void) {
    bool characters[UCHAR_MAX] = {0};

    unsigned char *s = "Hello, world!";

    while (*s) {
        characters[*s - 1] = 1;
        s++;
    }

    unsigned int r = 0;
    unsigned int i;
    for (i = 0; i < UCHAR_MAX; i++) {
        if (characters[i]) {
            r += 1;
        }
    }

    printf("%u\n", r);
    return 0;
}


Output:
1
10


Create a new paste based on this one


Comments: