Ich verwende zu C programmieren Geany( auf Lubuntu) mit gcc-version 4.7.3
Code: Alles auswählen
#include <stdio.h>
#include <stdlib.h>
struct ListItem
{
	int data;
	struct ListItem *next;
	struct ListItem *prev;
};
int main(void)
{
	struct ListItem a;
	a.data = 0;
	a.next = NULL;
	a.prev = NULL;
	struct ListItem b;
	b.data = 1;
	b.next = NULL;
	b.prev = NULL;
	struct ListItem c;
	c.data = 2;
	c.next = NULL;
	c.prev = NULL;
	
	a.next = &b;	// a zeigt auf b
	b.prev = &a;	// b zeigt auf a
	b.next = &c;	// b zeigt auf c
	c.prev = &b;	// c zeigt auf b
	
	int cnt = 0;
	for(ListItem *i = &a; i != NULL; i = i->next)
	{
		printf("Item %d value is %d\n\r",cnt , i->data);
		cnt++;
	}
	/*
	int cnt = 0;
	ListItem *i = NULL;
	for( *i = &a; i != NULL; i = i->next)
	{
		printf("Item %d value is %d\n",cnt , i->data);
		cnt++;
	}
	*/
	return 0;
}
Code: Alles auswählen
Fehler: unbekannter Typname >>ListItem<<
Fehler: Anfangsdeklaration in der >>for<<-Schleife sind nur imc99-modus erlaubtEs so zu schreiben wie es in dem Auskomentierten bereich steht bringt nichts
Vielen Dank für Eure Hilfe
Edit by cloidnerux: Code-Tags um Fehlermeldung


