所以我的程式假設接收用戶輸入的 4 個字串和一個 int 并將它們存盤在結構節點中并將它們放入佇列串列中,并且您有一個選單可以洗掉前面的節點或檢查每個節點的資訊它們但由于某種原因只顯示了 Int 變數,而存盤在 char[] 中的其他變數不顯示。我嘗試將列印功能放在不同的地方,并嘗試使用不同的方式來呼叫資訊,但沒有任何幫助。這里有一些代碼的 exceprts 和這里的完整鏈接https://hastebin.com/isahijoyer.cpp
case 3:
val = peek(q);
if (val != -1)
printf("\nAs informa??es do Aviao no inicio da fila s?o:\n");
printf("ID: %s\t", q->front->id);
printf("Numero De Passageiros: %d\t", val);
printf("Destino: %s\t", q->front->des);
printf("Empressa: %s\t", q->front->comp);
printf("Modelo: %s\t", q->front->mod);
break;
case 4:
q = display(q);
break;
case 5:
printf("Quantidade de avioes esperando eh: %d\t", cont);
break;
}
struct queue *display(struct queue *q)
{
struct node *ptr;
ptr = q -> front;
if(ptr == NULL)
printf("\nA FILA ESTA VAZIA\n");
else
{
printf("\n");
while(ptr!=q -> rear)
{
printf("ID: %s\t", ptr -> id);
ptr = ptr -> next;
}
printf("ID: %s\t", ptr -> id);
return q;
}
}
uj5u.com熱心網友回復:
struct queue *insert(struct queue *q,int val,char ide[10],char dest[10],char compa[10],char mode[10])
{
struct node *ptr;
ptr = (struct node*)malloc(sizeof(struct node));
ptr -> pass = val;
strcpy(ide, ptr->id);
strcpy(dest, ptr->des);
strcpy(compa, ptr->comp);
strcpy(mode, ptr->mod);
to的第一個引數strcpy是目的地。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/327455.html
標籤:C
上一篇:亂數生成器列印圖案
