Δημοσιεύτηκε: 07 Ιούλ 2011, 00:02
από Star_Light
Λοιπον αμα επιλυσω και αυτο το λαθακι τελειωσα με το μερος 2ο και πρακτικα και μπαινω μερος 3ο....

Κώδικας: Επιλογή όλων

/*==========================================================
YLOPOIHSH LISTAS ME SUNARTHSEIS

5/7/11

==========================================================
*/
#include<stdio.h>
#include<stdlib.h>

typedef struct customer /*xreiazetai kai i leksi customer wste na kserei mesa sto swma
tou se ti tupo anaferetai o deiktis next */
{
int id;
struct customer *next;
} Customer;

/*void list_print(Customer *head);*/
int main ()
{
Customer *head ,*newnode;

head = NULL;
newnode=NULL;

{
head= calloc(1,sizeof(Customer));
head->id=1;
head->next = NULL;
}

newnode= calloc(1,sizeof(Customer));
newnode->id=2;
newnode->next=NULL;
head->next=newnode;


/*while(head)
{
printf("%d \n\n", head->id);
head=head->next;
}*/

while(head)
{
printf("\n\n");
list_print(head);
head=head->next; /*Epeidi to au8entiko antigrafo tou head paramenei stin main() prepei na kiniseis pali ton deikti */
}


free(newnode->next); /*Katastrofi komvou ston opoio deixnei o newnode->next*/
free(newnode);
free(head);

if(head!=NULL)
printf("H free dn ekane kala tin douleia tis \n");
else
printf("H mnimi eleutherwthike!");


return 0;
}

void list_print(Customer *head)
{
while(head)
{
printf("%d",head->id);
head=head->next;
}
putchar('\n');
return;
}

/* BGAZEI SAN EKSODO 12 KAI 2 enw kanonika tha eprepe 1 kai 2*/


θα το ψαξω και μονος μου ταυτοχρονα.....