看板 Grad-ProbAsk 關於我們 聯絡資訊
要寫出這個程式的output 但是我打進電腦,一直有錯,我debug不出來,只好用腦子想....... 有些地方打結了,不太懂。 #include <stdio.h> #include <stdlib.h> typedef struct node{ char ch; struct node *link; } node_t, *list_t; void tupni (list_t *ptr, const char *s){ if(*s) { node_t *p = malloc(sizeof(node_t)); p->ch = *s; printf("%s",s); //這個應該是 abcd tunpi(&p->link, s+1); // &p->link 不懂,p的位址的link是什麼? printf("%c",p->ch); s+1也不懂,s指向下一筆char資料,可是 *ptr = p; 除了abcd還有什麼下一筆??? } else *ptr = NULL; } int main(void) { list_t p =NULL; tupni(&p, "abcd"); /* draw the list p */ } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.139.172.204
locallocal:你的ch定義不是array 不能存abcd 03/23 00:28