janmulder13
Gebruiker
- Lid geworden
- 15 sep 2009
- Berichten
- 43
Hallo,
Ik wil een functie die eigenlijk een array 'returnt'.
ik heb dit:[CPP]
bool **TextToData8(char symbol8) {
bool **data8;
char symbol[1];
symbol[0] = symbol8;
data8 = malloc(8);
data8[0] = malloc(8);
data8[1] = malloc(8);
data8[2] = malloc(8);
data8[3] = malloc(8);
data8[4] = malloc(8);
data8[5] = malloc(8);
data8[6] = malloc(8);
data8[7] = malloc(8);
int counterx = 0;
int countery = 0;
while (countery != 8) {
while (counterx != 8) {
data8[counterx][countery] = 0;
counterx++;
}
counterx = 0;
countery++;
}
counterx = 0;
countery = 0;
if (symbol8 == 'a') {
data8[1][0] = true; data8[2][0] = true; data8[3][0] = true;
data8[0][1] = true; data8[4][1] = true;
data8[0][2] = true; data8[4][2] = true;
data8[0][3] = true; data8[4][3] = true;
data8[0][4] = true; data8[1][4] = true; data8[2][4] = true; data8[3][4] = true; data8[4][4] = true;
data8[0][5] = true; data8[4][5] = true;
data8[0][6] = true; data8[4][6] = true;
return data8;
}
}
[/CPP]
Het 'returnt' data8, en dat doet hij ook alleen vanaf data8[>3][..] dan geeft hij niet de goede waarde.
TextToData('a')[4][2] geeft bijvoorbeeld 0 aan, terwijl hij duidelijk naar 1 wordt gezet in de code.
Hoe kan dit?
Alvast bedankt!
Jan.
Ik wil een functie die eigenlijk een array 'returnt'.
ik heb dit:[CPP]
bool **TextToData8(char symbol8) {
bool **data8;
char symbol[1];
symbol[0] = symbol8;
data8 = malloc(8);
data8[0] = malloc(8);
data8[1] = malloc(8);
data8[2] = malloc(8);
data8[3] = malloc(8);
data8[4] = malloc(8);
data8[5] = malloc(8);
data8[6] = malloc(8);
data8[7] = malloc(8);
int counterx = 0;
int countery = 0;
while (countery != 8) {
while (counterx != 8) {
data8[counterx][countery] = 0;
counterx++;
}
counterx = 0;
countery++;
}
counterx = 0;
countery = 0;
if (symbol8 == 'a') {
data8[1][0] = true; data8[2][0] = true; data8[3][0] = true;
data8[0][1] = true; data8[4][1] = true;
data8[0][2] = true; data8[4][2] = true;
data8[0][3] = true; data8[4][3] = true;
data8[0][4] = true; data8[1][4] = true; data8[2][4] = true; data8[3][4] = true; data8[4][4] = true;
data8[0][5] = true; data8[4][5] = true;
data8[0][6] = true; data8[4][6] = true;
return data8;
}
}
[/CPP]
Het 'returnt' data8, en dat doet hij ook alleen vanaf data8[>3][..] dan geeft hij niet de goede waarde.
TextToData('a')[4][2] geeft bijvoorbeeld 0 aan, terwijl hij duidelijk naar 1 wordt gezet in de code.
Hoe kan dit?
Alvast bedankt!
Jan.
Laatst bewerkt: