Advertisement
MeehoweCK

Untitled

Feb 2nd, 2021
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. // ZADANIE 21
  6. string* funkcja(char* tablica, int rozmiar)
  7. {
  8.     string* wynik = new string;     // zarezerwowanie pamięci na nowy obiekt typu string
  9.  
  10.     for(int i = 0; i < rozmiar; ++i)
  11.     {
  12.         (*wynik) += tablica[i];
  13.     }
  14.     return wynik;
  15. }
  16.  
  17. int main()
  18. {
  19.     char tab[5];
  20.     for(int i = 0; i < 5; ++i)
  21.         tab[i] = 'a' + i;
  22.     string* nowy = funkcja(tab, 5);
  23.     cout << *nowy;
  24.     delete nowy;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement