Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- int main()
- {
- using namespace std;
- char animal[20] = "kot";
- const char *bird = "mysz";
- char *ps;
- cout << animal << " oraz ";
- cout << bird << "\n";
- cout << "Podaj rodzaj zwierzecia: ";
- cin >> animal;
- ps = animal;
- cout << ps << "i!\n";
- cout << "Przed uzyciem strcpy():\n";
- cout << animal << " pod adresem " << (int *) animal << endl;
- cout << ps << " pod adresem " << (int *) ps << endl;
- ps = new char[strlen(animal) + 1];
- strcpy_s(ps, 20, animal);
- cout << "po uzyciu strcpy():\n";
- cout << animal << " pod adresem " << (int *) animal << endl;
- cout << ps << " pod adresem " << (int *) ps << endl;
- delete[] ps;
- cin.get();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment