Oh sorry so kompliziert will ich nicht denken. Da ich aber nicht komplett als Vollidiot darstellen will füge ich das gruppen zeug noch dazu (natürlich teste ich wieder nicht. dann kann man nämlich fehler machen ohne dass es einem zum verhängniss wird)
Code:
struct LIST
{
char* szName;
LIST* Next;
};
void DumpList(LIST* LIST)
{
LIST* Tmpg_LIST = LIST;
int i = 0;
while(Tmpg_LIST->Next)
{
printf("%i=>%s\n", i++, Tmpg_LIST->szName);
Tmpg_LIST = Tmpg_LIST->Next;
}
printf("%i=>%i\n", i++, Tmpg_LIST->szName);
}
bool IsInLinkedList(LIST* LIST, char* szSearchName)
{
LIST* Tmpg_LIST = LIST;
while(Tmpg_LIST->Next)
{
if(Tmpg_LIST->szName == szSearchName)
{
return true;
}
Tmpg_LIST = Tmpg_LIST->Next;
}
return Tmpg_LIST->szName == szSearchName;
}
bool AddToLinkedList(LIST* LIST,char* szAddName)
{
LIST* LastEntry = LIST;
while(LastEntry->Next)
{
LastEntry = LastEntry->Next;
}
LastEntry->Next = (LIST*) malloc(sizeof(LIST));
if(!LastEntry->Next)
{
return false;
}
LastEntry = LastEntry->Next;
LastEntry->szName = szAddName;
LastEntry->Next = 0;
return true;
}
Code:
#define MAX_PLAYER_NAME_LENGTH 32
int main()
{
char* szAllNames;
LIST* pGroups;
int iPlayers /* Maximal players NOT players per group*/, i = 0, j = 0, iTotalStrlen = 0, iGroups = 0;
scanf("%i", &iGroups);
pGroups = (LIST*) malloc(sizeof(LIST) * iGroups);
scanf("%i", &iPlayers);
szAllNames = (char*) malloc(MAX_PLAYER_NAME_LENGTH * iPlayers);
for(; j < iGroups; j++)
{
for(; i < iPlayers; i++)
{
scanf("%s", &szAllNames[iTotalStrlen]);
AddToLinkedList(pGroups[j], &szAllNames[iTotalStrlen]);
iTotalStrlen += strlen(&szAllNames[iTotalStrlen]);
}
}
for(; j < iGroups; j++)
DumpLinkedList(pGroups[j]);
free(szAllNames)
}