Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. struct Test {
  6.  
  7.   char* str;
  8.   int n;
  9.  
  10. };
  11.  
  12. void printTest(Test t)
  13. {
  14.     cout << t.str << endl;
  15.     cout << t.n << endl;
  16. }
  17.  
  18. int main()
  19. {
  20.    
  21.     int n = 1;
  22.     Test* mas = new Test[n];
  23.    
  24.     mas[0].n = 5;
  25.     mas[0].str = new char[10];
  26.     strcpy(mas[0].str, "Jack");
  27.    
  28.     printTest(mas[0]);
  29.    
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement