请帮忙看看这是怎么回事,怎么一用 a=a->next就出现core dumped
typedef struct mailNode MailNode;struct mailNode {
int msgNum;
char *from;
char *to;
char *subject;
char *date;
char *messageId;
char *inReplyTo;
enum statusCode status;
enum priorityCode priority;
char *content;
int year, month, day;
int hour, minute, second;
MailNode *next;
MailNode *revNext;
};
int main(int argc, char* argv[])
{
MailNode *messageList = NULL; // list of messages
FILE *fp = NULL;
int i=0;
char c;
char command[MAXLLENGTH]; // mail client command
if (argc != 2) { // Check for correct usage
fprintf(stderr, "Usage: %s file\n", argv[0]);
exit(1);
}
fp = openMailbox(argv[1]); // open mailbox file
while (i<7){
messageList = getNextMessage(fp);
messageList= messageList->next; //我可以把这个放到关文件之后,但为什么这里不能用next?我怎么才能实现让messageList复制所有getNextMessage(fp)的值? (另外getNextMessage(fp)这个函数是之前就提供的,并且不能改的。所以应该不是getNextMessage(fp)的问题。而且每次用getNextMessage(fp),指针自动+1)
i++;
}
fclose(fp); // We're done with the mailbox file
messageList->msgNum = 1;
//messageList=messageList->revNext;
printSynopsis( messageList );
// End of Stage 1
[ 本帖最后由 神的弃物 于 2009-10-8 18:58 编辑 ]