Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct product{
  6. char nazwa[30];
  7. int category;
  8. double price;
  9. } ;
  10. struct node{
  11. struct product *date;
  12. struct node *next;
  13. };
  14. node *f1(char * path){
  15. ifstream plik;
  16. plik.open(path);
  17. if(plik==NULL)return NULL;
  18. node * first==NULL;
  19. int category;
  20. char nazwa[30];
  21. double price;
  22. while(plik>>category&&plik>>nazwa&&plik>>price)==3{
  23. if(!list_find(first,name))
  24. list_add(&first,category,name,price);
  25. }
  26. plik.close();
  27. return first;
  28. }
  29.  
  30. bool list_find(node *first; char * name){
  31. while(first){
  32. if(strcmp(first->date->name;name)==0){
  33. return true;
  34. }
  35. first=first->next;
  36. }
  37. return 0;
  38. }
  39. void list_add(node **first int category,char *nazwa, double price){
  40. new node * n=(node *)malloc(sizeof(node));
  41. node->date=(product*)malloc(sizeof(product));
  42. n->date->category=category;
  43. n->date->price=price;
  44. strcpy(n->date->name,name);
  45. n->next=*first;
  46. *first=n;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement