ich bin ein Frischling was C angeht...habe mir in den letzten Tagen sehr viel durchgelesen und mich an Tutorial herangewagt. Nun ist es aber so das ich ein Projekt aufgebrummt bekommen habe das mir nicht so ganz liegt, es leigt auf einem anderen Level wie die Tutorials die ich gemacht habe. Ich soll bzw. muss eine Linkedlist erstellen die gewisse aufgaben erfüllen soll. Nun habe ich alles dazu durchgelesen was ich in die Hände bekommen habe und auch ein Paar Beispiele angeschaut, trotzdem komme ich nicht weiter, also ich stecke fest weiss nicht so ganz wie ich an die Sache herangehen soll. Ich studieren BWL und mein einer Professor hat uns eine Hausarbeit aufgegeben (was das mit unserem Fach genau zu tun hab weiss ich nicht, evtl will er uns nur eins reindrücken weil es immer so laut sind in der VL...

Ich schicke euch einmal den teil vom Code was ich gemacht hab...und ja evtl kann mir ja jemand helfen...
Code: Alles auswählen
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <stdint.h>
typedef struct node{
intptr_t data; //signed integer type which is guaranteed to be able to hold an address
struct node*next; //insert code here
void print_list(node_t * head) {
node_t * current = head;
while (current != NULL) {
printf("%d\n", current->val);
current = current->next;
}
}
int pop(node_t ** head) {
int retval = -1;
node_t * next_node = NULL;
if (*head == NULL) {
return -1;
}
next_node = (*head)->next;
retval = (*head)->val;
free(*head);
*head = next_node;
return retval;
}node_t;
typedef struct{
//insert code here....welche Liste denn?? Angaben daten???
void addToFront(intptr_t data)
{
node* tmp = new Node();
tmp -> data = data;
tmp -> next = head;
head = tmp;
}
void addToEnd(intptr_t data)
{
node* tmp = new Node();
tmp -> data = data;
tmp -> next = tail;
tail = tmp;
}
void RemoveFromFront(intptr_t data)
{
node* temp;
if(first == NULL)
{
cout<<"\nSingly Linked list is empty";
return;
}
if(first->link == NULL) //to check if only one node is present
{
temp = first;
first = NULL;
cout<<"\nDeleted node: "<<temp->data;
free(temp);
}
else //If more than one nodes are present
{
temp = first;
first = first->link;
cout<<"\nDeleted node: "<<temp->data;
free(temp);
}
}
void RemoveFromEnd(intptr_t data){
if(head != NULL){
ListNode *end = head;
ListNode *prev_end;
while(end->next != NULL){
prev_end = end;
end = end->next;
}
prev_end->next = NULL;
if(end != NULL) delete end;
size--;
}
}
}
}linkedList;
//prototypes of the functions that have to be implemented
linkedList* linkedList_generate();
void linkedList_free(linkedList* list);
void linkedList_addToFront(linkedList* list,intptr_t data);
void linkedList_addToEnd(linkedList* list,intptr_t data);
void linkedList_RemoveFromFront(linkedList* list);
void linkedList_RemoveFromEnd(linkedList* list);
void linkedList_print(linkedList* list,PrintMode mode);
//--tests --
void testList();
#endif
Danke für eure Hilfe schon einmal im vorraus!!!!