From 2316e3144cf7fea891df57d101403457b497c499 Mon Sep 17 00:00:00 2001 From: Yerolling <2911328695@qq.com> Date: Tue, 24 May 2022 21:16:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86PrintState=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bus_io.c b/src/bus_io.c index e46aa08..364c1f2 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -151,12 +151,13 @@ void PrintState(char *str) { memset(str, 0, 150); - int count; + int count, flag=1; //flag用于标记,为使下面第一个循环能够进入 rail_node_t *p = NULL; char target[20], clockwise[20], counterclockwise[20]; - for (count = 0, p = rails; p != NULL; p = p->next_node, count++) + for (count = 0, p = rails; flag==1 || p != NULL; p = p->next_node, count++) { + flag=0; target[count] = '0'; clockwise[count] = '0'; counterclockwise[count] = '0';