What does this do?



I have some globals declared such as:
1
2
3
4
5
6
7
char englishlist[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

char spanishlist[32] = {'a', a_accent, 'b', 'c', 'd', 'e', e_accent, 'f', 'g', 'h', 'i', i_accent, 'j', 'k', 'l', 'm', 'n', nyay, 'o', o_accent, 'p', 'q', 'r', 's', 't', 'u', u_accent, 'v', 'w', 'x', 'y', 'z'};

char germanlist[30] = {'a', a_umlaut, 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', o_umlaut, 'p', 'q', 'r', 's', sset, 't', 'u', u_umlaut, 'v', 'w', 'x', 'y', 'z'};

char * alphabet; 

alphabet is always assigned to one of the 3 language lists.

However, I have encountered that sometimes the computer can't tell the difference between the 3 alphabets.

so the code
if(isinit(a_accent, englishlist)) will sometimes return true.
However I have noticed that if I burp my program like a baby with the following code, subsequent calls to if(isinit()) behave correctly.
1
2
ofstream Fart, Puke, Vomit;
Fart << Puke << Vomit << englishlist << "!" << endl;

Unless I change the declaration of the arrays to const, then it still goes haywire. Of course this would seem that maybe its due a function improperly changing a parameter that should have been const, but this is far far far too simple to be a part of the curse affecting me.

Whats wrong with c++ my program?

PS what does Fart << Puke << Vomit do in the first place? Its directing the following to 3 ofstreams at once?
Last edited on
It probably should be const, but I doubt that's your problem.

What exactly does isinit() do? That seems to be where the trouble is, yet you didn't post the code for it.
It checks to see if a character is part of a string of characters. Useful for checking to see if a character is part of an alphabet, as I've come to realize isalpha() is very unreliable when working with alphabets other than english. For example: 'ñ', 'ó', 'ü' and 'ß'... are they alpha or not?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
bool isinit(const char & x, char * list)
{
    //if (!isalpha(x)) return false;

    if (!alpha(x))
        return false;

    int i = 0;

    while (list[i] != ' ')
        {
            if (list[i++] == x)
                return true;
        }
    return false;
}


edit: I see right away I should out to remove if (!alpha(x))
return false;
Wait I see that alpha is a func of my own design. I will have to take a look at it more closely, thanks
Last edited on
Look at line 10. You're checking for a space as a mark for the end of the list.

But look at your lists. None of them end with a space.
Topic archived. No new replies allowed.