#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
char *string;
struct node *next;
};
int eisagwgh(char str[],struct node **list);
int main()
{
char str[100];//99 το πολύ χαρακτήρες
struct node *list=NULL;
puts("Dwse:");
while(strcmp("end",gets(str)))//μέχρι να δώσεις end
if(eisagwgh(str,&list))puts("sfalma sthn desmeush mnhmhs.");
while(list!=NULL)
{
puts(list->string);
list=list->next;
}
return 0;
}
int eisagwgh(char str[],struct node **list)
{
struct node *neos;
neos=(struct node *)calloc(1,sizeof(struct node));
if(!neos)return 1;
neos->string=(char *)calloc(1,strlen(str)+1);
if(!neos->string)return 1;
strcpy(neos->string,str);
neos->next=*list;
*list=neos;
return 0;
}