Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Header.h"
- char* miyun(int counter,item *bla)
- {
- char *ptr;
- int *jtr;
- double *ztr;
- if (counter == 0)
- return bla->item_name;
- if (counter == 1)
- return bla->department;
- if (counter == 2)
- return bla->expiration_date;
- }
- void decompose(char* s, char **words,item* bla)
- {
- int counter = 0;
- while ((*s != '\0'))
- {
- while (strchr("_*_", *s))
- ++s;
- **words++;
- *words = s;
- while ((*s != '\0') && strchr("_*_", *s) == NULL)
- ++s;
- *s = '\0';
- if (counter<=2)
- strcpy(miyun(counter, bla), *words);
- if (counter == 3)
- bla->price = atof(*words);
- if (counter == 4)
- bla->available = atoi(*words);
- counter++;
- if (counter < 5)
- ++s;
- printf("%s ", *words);
- }
- // printf("%p", **words);
- // printf("%s", words);
- }
- int main()
- {
- item mozarslst[STORE_SIZE];
- item *mozar = mozarslst;
- char text[140];
- int count = 1;
- char *words[80];
- while (count<=1)
- {
- gets(text);
- decompose(text, words,mozar);
- mozar++;
- count++;
- printf("\n");
- }
- printf("\n%s", mozarslst[0].item_name);
- printf("\n%s", mozarslst[0].department);
- printf("\n%s", mozarslst[0].expiration_date);
- printf("\n%lf", mozarslst[0].price);
- printf("\n%d", mozarslst[0].available);
- // printf("\n%s", mozarslst[1].item_name);
- // printf("\n%s", mozarslst[1].department);
- // printf("\n%s", mozarslst[1].expiration_date);
- // printf("\n%lf", mozarslst[1].price);
- // printf("\n%d", mozarslst[1].available);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement