1
これは、2D配列に追加し、行ごとにグリッドに表示するためのコードです。 printf関数に基づいて2D配列に余分な文字を追加する
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");
}
}
、それだけで、次の座標に追加する必要があります。しかし、map(1)(4)、map(2)(4)、map(3)(4)、map(4)(4)は追加されていないprint *です。
余分な文字を追加しているコードの行が見つかりません