Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

31.12.2005, 16:29

Fragenthread zu C++ (Anfänger)

Hallo :)

also ich bin ja jetzt seid ca einer woche dabei C++ zu lernen mit den büchern C++ für Spieleprogrammierer und 3d Spiele Programmierung.

um jetzt mal die grundlagen bischen zu festigen, wollt ich des spaßes halber einfach mal ein rollenadventure schreiben, was halt nur text beinhaltet und keine grafiken :)

soweit läuft alles ganz gut, aber es kommt schon zu den ersten problemen, nämlich folgendes.

ich wollte ein system schreiben, wo ein held 25 statuspunkte am anfang verteilen kann und diese dann ausgegeben werden.

hier mal der nötige code dazu:

C-/C++-Quelltext

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 int GameStart()
{
    //Variablen for Persons

    int Strength, Intelligence, Alacrity, Flexibility, Armor;
    int Berserk, Mastery, UnholyStrength;
    char chName[30];
    int Damage, Hitpoints, Mana, Power ;
    int Auswahl = 0;
    //Variablen for Quests

    int Quest[5];


    
    //HeroMenue

    do {
        cout << "\n\n\n";
        cout << "--Charakter Auswahl--" << endl;
        cout << "1 - Warrior" << endl;
        cout << "2 - Magician" << endl;
        cout << "3 - Necromancer" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) :   //Warrior

            {
                WarriorInfo(&Strength, &Intelligence, &Alacrity, &Flexibility);
            } break;
        case (2):   //Magician

            {
                MagicianInfo(&Strength, &Intelligence, &Alacrity, &Flexibility);
                
            } break;
        case (3):   //Necromancer

            {
                NecromancerInfo(&Strength, &Intelligence, &Alacrity, &Flexibility);
            } break;
        default:
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
    } while(Auswahl != 1 && Auswahl != 2 && Auswahl != 3);

    //Calculate Hero Stat Points and cout


    cout << "Euer Held hat folgendes Ergebnis: " << endl;
    Armor = Alacrity + Flexibility/2;
    cout << "Ruestungswert: " << Armor << endl;
    cout << "Staerke: " << Strength << endl;
    cout << "Intelligenz: " << Intelligence << endl;
    cout << "Alacritiy: " << Alacrity << endl;
    cout << "Flexibilitaet: " << Flexibility << endl;


    return 0;

}


In diesem teil wird die funktion aufgerufen, der 3 charakterklassen und die werte staerke, etc. an nen pointer "übergeben".

dann folgendes für die statuspunkte:

C-/C++-Quelltext

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
void NecromancerInfo(int *pStrength, int *pIntelligence, int *pAlacrity, int *pFlexibility)
{
    //Variablen

    int Statpoints = 25;
    int Auswahl = 0;

    cout << endl;
    cout << "Klasse Necromancer ausgewaehlt!" << endl;
    cout << "Verteilen sie die Statuspunkte!" << endl;

    do {
        cout << "\n\n";
        cout << "" << Statpoints << " Statuspunkte uebrig." << endl;
        cout << "1 - Staerke" << endl;
        cout << "2 - Intelligenz" << endl;
        cout << "3 - Flexibilitaet" << endl;
        cout << "4 - Alacrity" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) :  //Strength

            {
                cout << "Staerke erhoeht!" << endl;
                pStrength++;
                Statpoints--;
            } break;
        case (2) :  //Intelligence

            {
                cout << "Intelligence erhoeht!" << endl;
                pIntelligence++;
                Statpoints--;
            } break;
        case (3) :  //Flexibilitaet

            {
                cout << "Flexibilitaet erhoeht!" << endl;
                pFlexibility++;
                Statpoints--;
            } break;
        case (4) :  //Intelligence

            {
                cout << "Alacrity erhoeht!" << endl;
                pAlacrity++;
                Statpoints--;
            } break;
        default:
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
    } while(Statpoints != 0);

    cout << "---------------------" << endl;
    cout << "Werte des Necromancer" << endl;
    pIntelligence += 7;
    pAlacrity += 7;
    pFlexibility += 3;
    pStrength += 2;
    cout << "Staerke: " << pStrength << endl;
    cout << "Intelligenz: " << pIntelligence << endl;
    cout << "Alacrity: " << pAlacrity << endl;
    cout << "Flexibilitaet: " << pFlexibility << endl;
    cout << "\n\n";

}


das ist dann die statauspunkte verteilung.

so als ergebnis kommt dann raus:

staerke: 87437843FGDGD .... halt die adresse der staerke variable z.b..
und genau das versteh ich eigentlich nicht. durch (&) sag ich der funktion, dass eine adresse übergeben wird und mit dem pointer wird die adresse angepeilt. da ich ja dann aber WERTE zuweise, müsste sich ja eigentlich auch die variable STRENGTH ändern und ausgegeben werden, aber das funktioniert nicht :(

weißt wer was daran falsch ist?

mfg
Simon

dot

Supermoderator

Beiträge: 9 757

Wohnort: Graz

  • Private Nachricht senden

2

31.12.2005, 16:40

Zitat

cout << "Staerke: " << *pStrength << endl;
cout << "Intelligenz: " << *pIntelligence << endl;
cout << "Alacrity: " << *pAlacrity << endl;
cout << "Flexibilitaet: " << *pFlexibility << endl;
cout << "\n\n";


würd ich mal sagen...

CW_Kovok

Alter Hase

Beiträge: 836

Wohnort: nähe Bonn

Beruf: Schüler

  • Private Nachricht senden

3

31.12.2005, 16:41

du erhöst mit pStrength++ die Adresse des Zeigers nicht den Inhalt! besser ist *pStrength++
Was es alles gibt, das ich nich brauche - Aristoteles

4

31.12.2005, 16:47

funktioniert trotzdem nicht ;)

staerke = 4357163

hmm ich stell mal den ganzen code rein... vl liegts an was anderem.

C-/C++-Quelltext

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
/*  Dracularks Castleadventure
    Version : 1.0
    Author : Simon Klausner */

#include <iostream>
#include <windows.h>

using namespace std;

//Klassen

/*class CPerson
{
protected:
    //Membervariablen
    int m_Hitspoints, m_Damage, m_Mana, m_Power, m_Armor;
    char m_chName[30];

public:
    //Memberfunktionen
    virtual void Attack();
    virtual void MagicAttack();
    virtual void PowerAttack();
};

//Magician Hero
class CHeroMagician : public CPerson
{
private:
    //Membervariablen
    int m_Strength, m_Intelligence, m_Alacrity, m_Flexibility;
    int m_Mastery;
public:
    //Memberfunktionen
    void MasteryAttack();

};

//Warrior Hero
class CHeroWarrior : public CPerson
{
private:
    //Membervariablen
    int m_Strength, m_Intelligence, m_Alacrity, m_Flexibility;
    int m_Berserk;
public:
    //Memberfunktionen
    void BerserkAttack();

};

//Necromancer Hero
class CHeroNecromancer : public CPerson
{
private:
    //Membervariablen
    int m_Strength, m_Intelligence, m_Alacrity, m_Flexibility;
    int m_UnholyStrength;
public:
    //Memberfunktionen
    void UnholyStrengthAttack();
}; */

//Funktionsprototypen

int GameStart();
void GameInfo();
void WarriorInfo(int *pStrength, int *pIntelligence, int *pAlacrity, int *pFlexibility);
void MagicianInfo(int *pStrength, int *pIntelligence, int *pAlacrity, int *pFlexibility);
void NecromancerInfo(int *pStrength, int *pIntelligence, int *pAlacrity, int *pFlexibility);


//Hauptprogramm


int main ()
{
    //Variablen

    int Auswahl = 0;


    //Welcome Text

    cout << "Willkommen zu Dracularks Castleadventure v 1.0" << endl;
    cout << "Waehle einen Menuepunkt aus." << endl;
    cout << "\n\n\n";

    //Menue

    do {
        cout << "\n\n\n";
        cout << "-----------------" << endl;
        cout << "1 - Spiel starten" << endl;
        cout << "2 - Infos" << endl;
        cout << "3 - Spiel beenden" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) :   //Gamestart

            {
                cout << "Spiel wird gestartet..." << endl;
                GameStart();
            } break;
        case (2):   //Information

            {
                cout << "Informationen zum Spiel... " << endl;
                GameInfo();
                
            } break;
        case (3):   //Quit Game

            {
                cout << "Spiel wird beendet..." << endl;
                cout << "Bis zum naechsten Mal." << endl;
            } break;
        default:
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
    } while(Auswahl != 3);

    return 0;

}

//GameInfo


void GameInfo()
{

    //Variablen

    int Auswahl = 0;

    //Infomenue


        
        
        do {
        cout << "\n\n\n";
        cout << "-----------------" << endl;
        cout << "1 - Allgemeine Infos" << endl;
        cout << "2 - Kampfsystem" << endl;
        cout << "3 - Aufgabe" << endl;
        cout << "4 - Info Ende" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) : //General Info

            {
                cout << "--------------Allgemeine Infos-----------------" << endl;
                cout << "Dracularks Castleadventure ist ein Rollenspiel," << endl;
                cout << "das meine (Simon) Programmierkenntnisse festigen" << endl;
                cout << "und verbessern soll :)" << endl;
                cout << "Anregungen oder Bugmeldungen?" << endl;
                cout << "Melde dich im ICQ : 321-881-927" << endl;
                
            } break;
        case (2) : //Battle System

            {
                cout << "-----------------------Kampfsystem-------------------------------" << endl;
                cout << "Das Kampsystem in Dracularks Castleadventure ist rundenbasierend." << endl;
                cout << "Der Charakter kaempft gegen bis zu 3 Gegner gleichzeitig" << endl;
                cout << "und kann Angreifen, Zaubern, Spezialattacken und der" << endl;
                cout << "entsprechenden Charakterklasse Superattacken ausfuehren." << endl;
                cout << "Wenn die Leben des Helden oder der Gegner auf 0 sinken" << endl;
                cout << "Hat man den Kampf gewonnen oder verloren." << endl;
                cout << "------------------------Werte------------------------------------" << endl;
                cout << "Nahkampfschaden = Basisschaden der Waffe + (Staerke * 3)" << endl;
                cout << "Zauberschaden = Basisschaden des Zaubers + (Intelligenz * 2)" << endl;
                cout << "Spezialattackenschaden = Basisschaden der Attacke + (Kraftpunkte * 1.5)" << endl;
                cout << "------------------------Superattacken----------------------------" << endl;
                cout << "Jede Charakterklasse verfueght ueber spezielle Superattacken." << endl;
                cout << "Warrior: Verfuegt uber Nahkampf-Superattacken und Auren." << endl;
                cout << "Magician: Verfuegt ueber Elementar-Superattacken und Schutzzaubern." << endl;
                cout << "Necromancer: Verfuegt uber Beschwoerungs-Superattacken." << endl;
            } break;
        case (3) : //Main Quest

            {
                cout << "---------------------Hauptaufgabe----------------" << endl;
                cout << "Die Hauptquest ist es, Draculark den Dunkeldaemon" << endl;
                cout << "zu besiegen. Ihr solltet dabei soviele Nebenquests" << endl;
                cout << "wie moeglich erledigen, um eine Chance gegen ihn zu" << endl;
                cout << "haben. Sammelt Items um euren Charakter zu verstaerken." << endl;
            } break;
        case (4) : //Quit Infomenue

            {
                cout << "-------------------------------" << endl;
                cout << "Information Ende!" << endl;
            } break;
        default :
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
        
        }while(Auswahl != 4);
    
}   

int GameStart()
{
    //Variablen for Persons

    int Strength, Intelligence, Alacrity, Flexibility, Armor;
    int Berserk, Mastery, UnholyStrength;
    char chName[30];
    int Damage, Hitpoints, Mana, Power ;
    int Auswahl = 0;
    //Variablen for Quests

    int Quest[5];


    
    //HeroMenue

    do {
        cout << "\n\n\n";
        cout << "--Charakter Auswahl--" << endl;
        cout << "1 - Warrior" << endl;
        cout << "2 - Magician" << endl;
        cout << "3 - Necromancer" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) :   //Warrior

            {
                WarriorInfo(&Strength, &Intelligence, &Alacrity, &Flexibility);
            } break;
        case (2):   //Magician

            {
                MagicianInfo(&Strength, &Intelligence, &Alacrity, &Flexibility);
                
            } break;
        case (3):   //Necromancer

            {
                NecromancerInfo(&Strength, &Intelligence, &Alacrity, &Flexibility);
            } break;
        default:
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
    } while(Auswahl != 1 && Auswahl != 2 && Auswahl != 3);

    //Calculate Hero Stat Points and cout


    cout << "Euer Held hat folgendes Ergebnis: " << endl;
    Armor = Alacrity + Flexibility/2;
    cout << "Ruestungswert: " << Armor << endl;
    cout << "Staerke: " << Strength << endl;
    cout << "Intelligenz: " << Intelligence << endl;
    cout << "Alacritiy: " << Alacrity << endl;
    cout << "Flexibilitaet: " << Flexibility << endl;


    return 0;

}

void WarriorInfo(int *pStrength, int *pIntelligence, int *pAlacrity, int *pFlexibility)
{
    //Variablen

    int Statpoints = 25;
    int Auswahl = 0;

    
    cout << endl;
    cout << "Klasse Warrior ausgewaehlt!" << endl;
    cout << "Verteilen sie die Statuspunkte!" << endl;

    do {
        cout << "\n\n";
        cout << "" << Statpoints << " Statuspunkte uebrig." << endl;
        cout << "1 - Staerke" << endl;
        cout << "2 - Intelligenz" << endl;
        cout << "3 - Flexibilitaet" << endl;
        cout << "4 - Alacrity" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) :  //Strength

            {
                cout << "Staerke erhoeht!" << endl;
                pStrength++;
                Statpoints--;
            } break;
        case (2) :  //Intelligence

            {
                cout << "Intelligence erhoeht!" << endl;
                pIntelligence++;
                Statpoints--;
            } break;
        case (3) :  //Flexibilitaet

            {
                cout << "Flexibilitaet erhoeht!" << endl;
                pFlexibility++;
                Statpoints--;
            } break;
        case (4) :  //Intelligence

            {
                cout << "Alacrity erhoeht!" << endl;
                pAlacrity++;
                Statpoints--;
            } break;
        default:
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
    } while(Statpoints != 0);

    cout << "------------------" << endl;
    cout << "Werte des Warriors" << endl;
    pStrength += 10;
    pAlacrity += 5;
    pFlexibility += 2;
    cout << "Staerke: " << pStrength << endl;
    cout << "Intelligenz: " << pIntelligence << endl;
    cout << "Alacrity: " << pAlacrity << endl;
    cout << "Flexibilitaet: " << pFlexibility << endl;
    cout << "\n\n";

}

void MagicianInfo(int *pStrength, int *pIntelligence, int *pAlacrity, int *pFlexibility)
{
    //Variablen

    int Statpoints = 25;
    int Auswahl = 0;

    cout << endl;
    cout << "Klasse Magician ausgewaehlt!" << endl;
    cout << "Verteilen sie die Statuspunkte!" << endl;

    do {
        cout << "\n\n";
        cout << "" << Statpoints << " Statuspunkte uebrig." << endl;
        cout << "1 - Staerke" << endl;
        cout << "2 - Intelligenz" << endl;
        cout << "3 - Flexibilitaet" << endl;
        cout << "4 - Alacrity" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) :  //Strength

            {
                cout << "Staerke erhoeht!" << endl;
                pStrength++;
                Statpoints--;
            } break;
        case (2) :  //Intelligence

            {
                cout << "Intelligence erhoeht!" << endl;
                pIntelligence++;
                Statpoints--;
            } break;
        case (3) :  //Flexibilitaet

            {
                cout << "Flexibilitaet erhoeht!" << endl;
                pFlexibility++;
                Statpoints--;
            } break;
        case (4) :  //Intelligence

            {
                cout << "Alacrity erhoeht!" << endl;
                pAlacrity++;
                Statpoints--;
            } break;
        default:
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
    } while(Statpoints != 0);

    cout << "------------------" << endl;
    cout << "Werte des Magician" << endl;
    pIntelligence += 15;
    pFlexibility += 5;
    cout << "Staerke: " << pStrength << endl;
    cout << "Intelligenz: " << pIntelligence << endl;
    cout << "Alacrity: " << pAlacrity << endl;
    cout << "Flexibilitaet: " << pFlexibility << endl;
    cout << "\n\n";

}

void NecromancerInfo(int *pStrength, int *pIntelligence, int *pAlacrity, int *pFlexibility)
{
    //Variablen

    int Statpoints = 25;
    int Auswahl = 0;

    cout << endl;
    cout << "Klasse Necromancer ausgewaehlt!" << endl;
    cout << "Verteilen sie die Statuspunkte!" << endl;

    do {
        cout << "\n\n";
        cout << "" << Statpoints << " Statuspunkte uebrig." << endl;
        cout << "1 - Staerke" << endl;
        cout << "2 - Intelligenz" << endl;
        cout << "3 - Flexibilitaet" << endl;
        cout << "4 - Alacrity" << endl;
        cout << "Menuepunkt: " << endl;
        cin >> Auswahl;

        switch (Auswahl)
        {
        case (1) :  //Strength

            {
                cout << "Staerke erhoeht!" << endl;
                *pStrength++;
                Statpoints--;
            } break;
        case (2) :  //Intelligence

            {
                cout << "Intelligence erhoeht!" << endl;
                pIntelligence++;
                Statpoints--;
            } break;
        case (3) :  //Flexibilitaet

            {
                cout << "Flexibilitaet erhoeht!" << endl;
                pFlexibility++;
                Statpoints--;
            } break;
        case (4) :  //Intelligence

            {
                cout << "Alacrity erhoeht!" << endl;
                pAlacrity++;
                Statpoints--;
            } break;
        default:
            {
                cout << "Fehler in der Eingabe!" << endl;
            }
        }
    } while(Statpoints != 0);

    cout << "---------------------" << endl;
    cout << "Werte des Necromancer" << endl;
    pIntelligence += 7;
    pAlacrity += 7;
    pFlexibility += 3;
    *pStrength += 2;
    cout << "Staerke: " << *pStrength << endl;
    cout << "Intelligenz: " << pIntelligence << endl;
    cout << "Alacrity: " << pAlacrity << endl;
    cout << "Flexibilitaet: " << pFlexibility << endl;
    cout << "\n\n";

}

Black-Panther

Alter Hase

Beiträge: 1 443

Wohnort: Innsbruck

  • Private Nachricht senden

5

31.12.2005, 17:08

Wie schon gesagt wurde, erhöhst du die Adresse auf welche der pointer zeigt...
Demnach müsste der Code in den 3 Funktionen verändert werden: (habs jetzt nur bei einer Funktion gemacht...)

C-/C++-Quelltext

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
do { 
        cout << "\n\n"; 
        cout << "" << Statpoints << " Statuspunkte uebrig." << endl; 
        cout << "1 - Staerke" << endl; 
        cout << "2 - Intelligenz" << endl; 
        cout << "3 - Flexibilitaet" << endl; 
        cout << "4 - Alacrity" << endl; 
        cout << "Menuepunkt: " << endl; 
        cin >> Auswahl; 

        switch (Auswahl) 
        { 
        case (1) :    //Strength 

            { 
                cout << "Staerke erhoeht!" << endl; 
                (*pStrength)++; 
                Statpoints--; 
            } break; 
        case (2) :    //Intelligence 

            { 
                cout << "Intelligence erhoeht!" << endl; 
                (*pIntelligence)++; 
                Statpoints--; 
            } break; 
        case (3) :    //Flexibilitaet 

            { 
                cout << "Flexibilitaet erhoeht!" << endl; 
                (*pFlexibility)++; 
                Statpoints--; 
            } break; 
        case (4) :    //Intelligence 

            { 
                cout << "Alacrity erhoeht!" << endl; 
                (*pAlacrity)++; 
                Statpoints--; 
            } break; 
        default: 
            { 
                cout << "Fehler in der Eingabe!" << endl; 
            } 
        } 
    } while(Statpoints != 0); 

    cout << "------------------" << endl; 
    cout << "Werte des Warriors" << endl; 
    *pStrength += 10; 
    *pAlacrity += 5; 
    *pFlexibility += 2; 
    cout << "Staerke: " << *pStrength << endl; 
    cout << "Intelligenz: " << *pIntelligence << endl; 
    cout << "Alacrity: " << *pAlacrity << endl; 
    cout << "Flexibilitaet: " << *pFlexibility << endl; 
    cout << "\n\n";
stillalive studios
Drone Swarm (32.000 Dronen gleichzeitig steuern!)
facebook, twitter

6

31.12.2005, 17:10

ja ich hab das ja gemacht bei staerke z.b. und es funktioniert (zumindest bei mir) trotzdem nicht. als wert wird dann 437612 oder so ausgegeben, obwohls 25 staerke oder so sein sollte :/

Black-Panther

Alter Hase

Beiträge: 1 443

Wohnort: Innsbruck

  • Private Nachricht senden

7

31.12.2005, 17:14

^^ Soweit ich sehe hast du die Variablen nie initialisiert... Mach das bei der Deklaration und setzt sie dor auf 0, dann funktionierts...

C-/C++-Quelltext

1
2
 //Variablen for Persons 

    int Strength = 0, Intelligence = 0, Alacrity = 0, Flexibility = 0, Armor = 0;
stillalive studios
Drone Swarm (32.000 Dronen gleichzeitig steuern!)
facebook, twitter

8

31.12.2005, 18:47

wenn ich das mache kommt für stärke folgendes raus:D

staerke: -858993458

Anonymous

unregistriert

9

31.12.2005, 18:48

Draculark
Debuggen ^^ Denn das ist der Initialisierungswert der Variable.

10

31.12.2005, 18:52

so hab was entdeckt... lustig aber wahr :D

wenn ich die zeile

*pStrength ++;

auf

*pStrength += 1;

ändere funktionierts plötzlich ... warum eigentlich wenn ich fragen darF? ;)

Werbeanzeige