summaryrefslogtreecommitdiff
path: root/unique-char.cpp
blob: b8120b2b8dda377d047af5b079f10f16f109acdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

bool is_unique(const char* p, size_t n)
{
    static const char offset = 'a';
    size_t counts[26];
    for (size_t i = 0; i < n; ++i, ++p)
    {
        char c = *p;
        cout << *p << endl;
    }

    return true;
}

int main(int argc, char** argv)
{
    if (argc < 2)
    {
        cout << "needs at least one argument" << endl;
        return EXIT_FAILURE;
    }

    cout << "input string: " << argv[1] << endl;

    size_t n = strlen(argv[1]);
    const char* p = argv[1];
    cout << "all characters are unique: " << (is_unique(p, n) ? "yes" : "no") << endl;

    return EXIT_SUCCESS;
}