Hallo,
ich nochmal
Also ich habe da ein Problem mit meiner Klasse. Diese hat jetzt 2 Methoden. setKey() und printKey(). Aber wenn ich den Key mit setKey() setze und danach printKey() ausführe, dann hat der Key komplett andere Werte als er haben sollte. Hab schon einiges ausprobiert aber ich komm da nicht weiter. Vielleicht kann mir hier ja wieder mal einer helfen.
die Klasse IDEA:
und meine Main.cpp zum testen:
Weiß echt ncht mehr weiter. Vielleicht habe ich da was grundsätzliches zum Thema Zeiger nich verstanden... ka.
Gruß Martin
ich nochmal
Also ich habe da ein Problem mit meiner Klasse. Diese hat jetzt 2 Methoden. setKey() und printKey(). Aber wenn ich den Key mit setKey() setze und danach printKey() ausführe, dann hat der Key komplett andere Werte als er haben sollte. Hab schon einiges ausprobiert aber ich komm da nicht weiter. Vielleicht kann mir hier ja wieder mal einer helfen.
die Klasse IDEA:
Code:
#include <cstdlib>
#include <iostream>
#define WORD unsigned short int
class IDEA
{
private:
WORD Key[7];
WORD* Key_pt;
void setKey(WORD* aKey)
{
for(int i = 0; i++; i <= 7)
Key[i] = *aKey; aKey++;
}
void printKey()
{
int j = 0;
while(j <= 7)
{ printf("%X ", Key[j]); j++; }
}
};
und meine Main.cpp zum testen:
Code:
#include <cstdlib>
#include <iostream>
#include <E:\Projekte\C\EncryptionTool\idea.cpp>
#define WORD unsigned short int
using namespace std;
int main(int argc, char *argv[])
{
IDEA text;
WORD Key[7];
WORD* Key_pt = &Key[0];
WORD SubKey[55];
WORD* SubKey_pt;
Key[0] = 1;
Key[1] = 2;
Key[2] = 3;
Key[3] = 4;
Key[4] = 5;
Key[5] = 6;
Key[6] = 7;
Key[7] = 8;
int i = 0;
while(i <= 7)
{
printf("%X ", *Key_pt); Key_pt++; i++; }
Key_pt = &Key[0];
text.setKey(Key_pt);
text.printKey();
system("PAUSE");
return EXIT_SUCCESS;
}
Weiß echt ncht mehr weiter. Vielleicht habe ich da was grundsätzliches zum Thema Zeiger nich verstanden... ka.
Gruß Martin