以下是函数
//printList for Debugging
void printList(letterListT *head){
letterListT *temp = head;
while(temp != NULL){
printf("%c ", temp->letter);
temp = temp->nxt;
}
}
//Add the Specified Letter by Creating a New Node in the Letter List defined
void addLetter(letterListT *letListHead, char letter){
letterListT *newNode;
newNode = (letterListT *)malloc(sizeof(letterListT));
newNode->letter = letter;
newNode->nxt = letListHead->nxt;
letListHead->nxt = newNode;
}这些是main中的:
unusedLetList = (letterListT *)malloc(sizeof(letterListT));
unusedLetList->nxt = NULL;
for(i=122; i>=97; i--){ //ascii codes for z to a
addLetter(unusedLetList, i);
}
//printlists Test
printList(unusedLetList);这是输出..。
p a b c d e f g h i j k l m n o p q r s t u v w x y z 我的问题是。这个“p”是从哪里来的?!
发布于 2012-12-17 05:49:40
列表头节点。
unusedLetList = (letterListT *)malloc(sizeof(letterListT));
unusedLetList->nxt = NULL;在这里创建一个head节点,然后在head节点后面添加每个字母。头节点具有未初始化的->letter字段。它可以是任何东西;它恰好是p。
https://stackoverflow.com/questions/13905772
复制相似问题