Guest User

Untitled

a guest
Oct 26th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. int main()
  4. {
  5. using namespace std;
  6. char animal[20] = "kot";
  7. const char *bird = "mysz";
  8. char *ps;
  9.  
  10. cout << animal << " oraz ";
  11. cout << bird << "\n";
  12.  
  13. cout << "Podaj rodzaj zwierzecia: ";
  14. cin >> animal;
  15.  
  16. ps = animal;
  17. cout << ps << "i!\n";
  18. cout << "Przed uzyciem strcpy():\n";
  19. cout << animal << " pod adresem " << (int *) animal << endl;
  20. cout << ps << " pod adresem " << (int *) ps << endl;
  21.  
  22. ps = new char[strlen(animal) + 1];
  23. strcpy_s(ps, 20, animal);
  24. cout << "po uzyciu strcpy():\n";
  25. cout << animal << " pod adresem " << (int *) animal << endl;
  26. cout << ps << " pod adresem " << (int *) ps << endl;
  27. delete[] ps;
  28. cin.get();
  29. cin.get();
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment