Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include "Header.h"
  2. char* miyun(int counter,item *bla)
  3. {
  4. char *ptr;
  5. int *jtr;
  6. double *ztr;
  7. if (counter == 0)
  8. return bla->item_name;
  9. if (counter == 1)
  10. return bla->department;
  11. if (counter == 2)
  12. return bla->expiration_date;
  13. }
  14.  
  15. void decompose(char* s, char **words,item* bla)
  16. {
  17. int counter = 0;
  18. while ((*s != '\0'))
  19. {
  20. while (strchr("_*_", *s))
  21. ++s;
  22. **words++;
  23. *words = s;
  24. while ((*s != '\0') && strchr("_*_", *s) == NULL)
  25. ++s;
  26. *s = '\0';
  27. if (counter<=2)
  28. strcpy(miyun(counter, bla), *words);
  29. if (counter == 3)
  30. bla->price = atof(*words);
  31. if (counter == 4)
  32. bla->available = atoi(*words);
  33. counter++;
  34. if (counter < 5)
  35. ++s;
  36.  
  37. printf("%s ", *words);
  38.  
  39. }
  40. // printf("%p", **words);
  41. // printf("%s", words);
  42. }
  43. int main()
  44. {
  45. item mozarslst[STORE_SIZE];
  46. item *mozar = mozarslst;
  47. char text[140];
  48. int count = 1;
  49. char *words[80];
  50. while (count<=1)
  51. {
  52. gets(text);
  53. decompose(text, words,mozar);
  54. mozar++;
  55. count++;
  56. printf("\n");
  57.  
  58. }
  59. printf("\n%s", mozarslst[0].item_name);
  60. printf("\n%s", mozarslst[0].department);
  61. printf("\n%s", mozarslst[0].expiration_date);
  62. printf("\n%lf", mozarslst[0].price);
  63. printf("\n%d", mozarslst[0].available);
  64. // printf("\n%s", mozarslst[1].item_name);
  65. // printf("\n%s", mozarslst[1].department);
  66. // printf("\n%s", mozarslst[1].expiration_date);
  67. // printf("\n%lf", mozarslst[1].price);
  68. // printf("\n%d", mozarslst[1].available);
  69.  
  70.  
  71.  
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement