Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include "slovar.h"
  2.  
  3. using namespace std;
  4.  
  5. void Input(slovar &s)
  6. {
  7. char buf[256];
  8. cout << "Введите имя автора" << endl;
  9. scanf_s("%s", &buf, 256);
  10. s.autor = new char[strlen(buf)+1];
  11. strcpy_s(s.autor, 255, buf);
  12. cout<< "Введите кол-во произведений, написанных автором" << endl;
  13. scanf_s("%d", &s.numberstr);
  14. cout << "Введите произведения, написанные автором" << endl;
  15. for (int i = 0; i < s.numberstr; i++)
  16. {
  17. scanf_s("%85s", &buf, 85);
  18. printf("%d\n",strlen(buf));
  19. s.strings[i] = (char*) malloc(strlen(buf)+1);
  20. strcpy_s(s.strings[i], strlen(buf)+1, buf);
  21. }
  22.  
  23. }
  24.  
  25. void Output(slovar &s)
  26. {
  27. printf("\nАвтор: %s, произведения: ", s.autor);
  28. for (int i = 0; i < s.numberstr; i++)
  29. {
  30. printf("%s ", s.strings[i]);
  31. delete(s.strings[i]);
  32. }
  33. }
  34.  
  35. int main()
  36. {
  37. slovar s;
  38. setlocale(0, "rus");
  39. Input(s);
  40. Output(s);
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement