Hello,
i have to read in a word, it should come in a char Array. But if there is a letter twice, e.g. password it only should read in pasword. I tried it with for and if grinds, but it doesn´t worked. I tried:
Schluessel is the char with the entered word, hear password
in 'key' should come the new word, hear pasword
for(int i=0;Schluessel[i]!='\0';i++){
for(int j=0;key[j]='\0';j++){
if(Schluessel[i]!=key[j]){
key[j]=Schluessel[i];
cout<<key[j];
}
}
}
It doesn´t worked, because of the emty char 'key'. i tried it with the lenght of Schluessel but it doesn´t worked.
i´ll be happy if someone could help me.
#include <iostream>
int main()
{
char alphabet[26] = { 0 };
char word[] = "BOO!";
int length = sizeof(word) / sizeof(char);
int index = 0;
for (int i = 0; i < length; i++)
{
index = word[i] - 'a';
///////////////// added ////////////////////
if( index < 0 || index >= int( sizeof(alphabet) ) )
std::cout << "\nabout to access char at alphabet[" << index << "] (undefined behaviour)\n" ;
///////////////// added ////////////////////
if (alphabet[index] < 1)
std::cout << word[i];
alphabet[index]++;
}
return 0;
}
about to access char at alphabet[-31] (undefined behaviour)
B
about to access char at alphabet[-18] (undefined behaviour)
O
about to access char at alphabet[-18] (undefined behaviour)
about to access char at alphabet[-64] (undefined behaviour)
about to access char at alphabet[-97] (undefined behaviour)
To answer your question lechuga2000 my program handles uppercase and beyond by adjusting the size of the alphabet (currently 26 on line 5) and starting point ( currently 'a' on line 13) character in the ASCII table. You can probably see this without me demonstrating. We could make it the whole of the ASCII table but that doesn't seem to show how it works without comments, my preference.
I think the ASCII table is fairly universal, well at least where humans like me are concerned. You would know there aren't too many problems there. :)
As we can see, the scale of the problem shouldn't be too much of a problem. There are not many characters involved in even the longest passwords and key phrases around and considering the full ASCII table is about 200 characters or whatever, the test time is minuscule even if your best computer is a TRS80.
You might like to let me know how my program goes after you modify it for user input. My guess is the test would be easily quicker than keystroke time. It obviously wouldn't be good if the time was substantial and interfered, but I haven't tried it. I'll leave it to you if you're interested. I have other commitments unfortunately.
Excellent points you raise. Best wishes.
Cheers :)
LOL, we'll need to test it with German umlauts lechuga. You're coming up with the sort of question an experienced testing team would need to address. Whole character sets would need your scrutiny, Greek, Hebrew, you name it.
On the readability question you so ably have turned your mind to I am confident at least in principle kanji and Chinese characters would be manageable. As you would no doubt be fully aware we could say readability is a local issue. I'm limited to English, Spanish, Mandarin and Thai but who knows what languages my program needs to be applied to. Just a couple of simple adjustments I suspect. You could check those out for me too.
Good and thoughtful questions again.
Cheers and best wishes :)
You'll notice I left out the german keyboard characters in my revision above which dispels most if not all uncertainty about its flexibility.
You raise an interesting point again but I have no knowledge on being a native english speaker where umlauts are not de rigueur. We live comfortably without them although I find French cedillas somewhat engaging and characteristically stylish. Alas I don't use them either. Yahoo might, can I suggest you check and report back to me on that.
Does yahoo in the fatherland, or whatever they call it these days, accept passwords with alt+nnn characters? These are deep questions my otherwise universal program has not managed to address but given its sophistication and your diligent testing and appraisal I am sure it can prevail in normal password security regimes in the world outside the germanic tribal areas, if not within.
Regional cheers and greetings,
Best of good wishes:)