以前の質問から、リンクされたリストが更新されなかった理由がわかりました。x の座標を繰り返し処理する必要があることがわかりましたが、それは私のこの質問では重要ではありません。
リンクされたリストに要素を挿入すると、値を挿入したい場所の前の要素が消えます。たとえば、「helo」を出力する要素があり、e の後に別の「l」を挿入したい場合、出力は「(space)ello」になります。挿入コードと構造は次のとおりです。
struct node {
struct node *previous;
int c;
int x;
int y;
struct node *next;
}*head;
void checker(int ch, int xpos, int ypos)
{
int flag=0;
struct node *temp,*temp1,*var,*insert_node;
var=(struct node *)malloc(sizeof(struct node));
temp=(struct node *)malloc(sizeof(struct node));
insert_node=(struct node*)malloc(sizeof(struct node));
temp=head;
while(temp!=NULL)
{
if(temp->x==xpos && temp->y==ypos)
{
insert_node->c=ch;
insert_node->x=xpos;
insert_node->y=ypos;
insert_node->next=NULL;
temp1=temp;
while(temp1!=NULL)
{
if(temp1->y==ypos)
temp1->x++;
temp1=temp1->next;
}
var->next=insert_node;
insert_node->next=temp;
head=var;
flag=1;
break;
}
var=temp;
temp=temp->next;
}
if(flag==0)
characters(ch,xpos,ypos);
}
var の内部には 2 つではなく 1 つの要素しかないようです。helo から "h" を忘れてしまいます。