私のエラーはどういう意味ですか? どうすれば修正できますか?
プログラムを実行しようとしたときのエラーの写真については、こちらを参照してください...
http://postimg.org/image/horh6d26j/
私のプログラムは、二重連結リストの最後の要素を削除して先頭に挿入しようとしています
backToFront 関数を実行しようとしているだけです。このアクティビティは、私の大学で 2011 年に実施された過去の実習試験です(?)。2 日後に行われる実習試験の準備として完了しようとしています (aaahhhhhhh !!!!!!)
/*
* backToFront.c
* comp1917 pracExam #2 2011s1 UNSW
*
* Author: WRITE YOUR NAME HERE
* Date: 21 June 2011
* License: Public Domain
*/
// Implement the backToFront function below
// so that it moves the last node in a non-empty linked list
// of nodes to be the first node in the list, leaving the
// relative position of all the other nodes unchanged.
// You may assume the input list contains at least one node.
//
// Your function should do the moving by changing pointers
// in the nodes and list structs, (don't use malloc or make
// any new nodes)
//
// Your function should return the new list.
//
// You need to pass the tests in testBackToFront.c
//
// Compile and run the tests using
// gcc -Wall -Werror -O -o tester backtToFront.c testBackToFront.c
// ./tester
//
// When a test fails look in the testBackToFront.c file to see
// what the test was testing. There are 3 tests in that file.
//
// Once you have passed all the tests you have finished.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "backToFront.h"
list backToFront (list items) {
assert (items.first != NULL);
nodePtr current = items.first;
nodePtr previous = NULL;
while (current != NULL){
previous = current;
current = current->rest;
}
current->rest = items.first;
items.first = current;
previous->rest = NULL;
return items;
}
/*
* backToFront.h
* pracExam 2011
*
* Created by Richard Buckland on 26/07/09.
* Modified by David Collien on 20/06/11.
* Copyright 2011. All rights reserved.
*
*/
// DO NOT ALTER OR SUBMIT THIS FILE
// we will use our own copy when marking
typedef struct _node *nodePtr;
typedef struct _list {
nodePtr first;
} list;
// For le sorution, add /samplesolutions at the end of your url
typedef struct _node {
int value;
nodePtr rest;
} node;
// given a node (*item) and a list of nodes (items)
// this function takes the last node of the list
// and moves it to be the first node in the list.
//
// the function returns the altered list.
//
// (note that the function does not create new nodes
// or change the value field of existing nodes.)
list backToFront (list items);