Aangezien m'n C++ boek me niet kon helpen, verwacht ik dat jullie dat wel kunnen 
Ja, input heeft de juiste waarde ( voorbeeld door programma uitgespuugd ) :
Maar in het xml bestand staat:
Wat is het probleem?
C++:
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
| #include <iostream> #include <stdio.h> #include <cstring> using namespace std; int main( int argc, char *argv[] ) { // Define input vars string card[9]; // Ask user to input cout << "Type of card? ( eg. Monster )\n"; cin >> card[0]; cout << "\nFilename of card image? ( eg. Monster.bmp )\n"; cin >> card[1]; cout << "\nName of the card? ( eg. Blue Eyes White Dragon )\n"; cin >> card[2]; cout << "\nWhat is the type of the card? ( eg. Dark )\n"; cin >> card[3]; cout << "\nWhat is the card's amount of stars? ( eg. 7 )\n"; cin >> card[4]; cout << "\nWhat is the cards description? ( eg. ultimate wizard in terms of attack and defence )\n"; cin >> card[5]; cout << "\nWhat is the cards effect? ( eg. Flip: destroy one faced up monster on the field )\n"; cin >> card[6]; cout << "\nHow many attack points has the card? ( eg. 1500 )\n"; cin >> card[7]; cout << "\nHow many defense points has the card? ( eg. 1200 )\n"; cin >> card[8]; cout << "\n"; FILE *fp; if( ( fp = fopen( "carddatabase.xml", "a+" ) ) == NULL ) { cout << "Cannot open file!" << endl; return 1; } string input; input = "<card type=\"" + card[0] + "\" src=\"" + card[1] + "\">" + "\n"; input += "<name>" + card[2] + "</name>" + "\n"; input += "<type>" + card[3] + "</type>" + "\n"; input += "<level>" + card[4] + "</level>" + "\n"; input += "<description>" + card[5] + "</description>" + "\n"; input += "<effect>" + card[6] + "</effect>" + "\n"; input += "<attack>" + card[7] + "</attack>" + "\n"; input += "<defense>" + card[8] + "</defense>" + "\n"; input += "</card>\n"; cout << input; fwrite( &input, sizeof( input ), sizeof( input ), fp ); fclose( fp ); cout << "Wrote to file!" << endl; system( "pause" ); return 0; } |
Ja, input heeft de juiste waarde ( voorbeeld door programma uitgespuugd ) :
XML:
1
2
3
4
5
6
7
8
9
| <card type="Monster" src="M.bmp"> <name>BEWD</name> <type>Dark</type> <level>7</level> <description>None</description> <effect>Blaat</effect> <attack>2100</attack> <defense>1200</defense> </card> |
Maar in het xml bestand staat:
code:
1
2
3
4
5
6
| T<= ã¿w ¹7= |
Wat is het probleem?