Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct product{
- char nazwa[30];
- int category;
- double price;
- } ;
- struct node{
- struct product *date;
- struct node *next;
- };
- node *f1(char * path){
- ifstream plik;
- plik.open(path);
- if(plik==NULL)return NULL;
- node * first==NULL;
- int category;
- char nazwa[30];
- double price;
- while(plik>>category&&plik>>nazwa&&plik>>price)==3{
- if(!list_find(first,name))
- list_add(&first,category,name,price);
- }
- plik.close();
- return first;
- }
- bool list_find(node *first; char * name){
- while(first){
- if(strcmp(first->date->name;name)==0){
- return true;
- }
- first=first->next;
- }
- return 0;
- }
- void list_add(node **first int category,char *nazwa, double price){
- new node * n=(node *)malloc(sizeof(node));
- node->date=(product*)malloc(sizeof(product));
- n->date->category=category;
- n->date->price=price;
- strcpy(n->date->name,name);
- n->next=*first;
- *first=n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement