Posted By

cristy1126 on 05/27/13


Tagged

lista creare functie


Versions (?)

Creare lista


 / Published in: C
 

URL: http://ssm-iscir.ro

Functie creare lista simpla inalntuita

  1. // se defineste structura
  2.  
  3. struct numar {
  4. int valoare;
  5. struct numar *next;
  6. };
  7.  
  8.  
  9.  
  10. struct numar *prim = NULL;
  11. struct numar *ultim = NULL;
  12.  
  13. //functie creare
  14.  
  15. struct numar *creare(int val){
  16. struct numar *ptr = (struct numar*)malloc(sizeof(struct numar));
  17. if (NULL == ptr){
  18. printf("\nNu se poate crea nodul\n");
  19. return NULL;
  20. }
  21.  
  22. ptr->valoare = val;
  23. prim = ultim = ptr;
  24. }

Report this snippet  

You need to login to post a comment.