Dies ist mein Code zum Anhängen an das 2D-Array und zum Anzeigen von Zeile für Zeile in einem Raster.2D-Array fügt zusätzliches Zeichen hinzu
void map_print() {
char map[head->xdim][head->ydim]; // Generate 2D array for map
memset(map, 0, sizeof(map));
FEATURE *temp=head->next; // Get the pointer of the head of linked list
while(temp!=NULL) // Generated the map with the features
{
for (int xdim = 0; xdim < temp->xdim; xdim++){
map[temp->yloc][temp->xloc + xdim] = temp->type;
printf("X axis: Appeding to map[%d][%d]\n",temp->yloc,temp->xloc+xdim);
}
for (int ydim = 0; ydim < temp->ydim; ydim++){
map[temp->yloc + ydim][temp->xloc] = temp->type;
printf("Y axis: Appeding to map[%d][%d]\n",temp->yloc + ydim,temp->xloc);
}
temp=temp->next;
}
for (int i = 0; i < head->ydim; i++) { // Print out the map
for (int j = 0; j < head->xdim; j++) {
//printf("%c ", map[i][j]);
printf("map[%d][%d](%c)",i,j,map[i][j]);
}
printf("\n");
}
}
Basierend auf dem printf, sollte es nur auf die folgenden Koordinaten anhängen. Die Karte (1) (4), die Karte (2) (4), die Karte (3) (4), die Karte (4) (4) drucken jedoch *, die ich nicht angehängt habe.
Ich kann nicht jede Linie meines Code finden, dass zusätzliches Zeichen hinzugefügt wird