Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5. char* funkcja(char *tab)
  6. {
  7. int a;
  8. a=strlen(tab);
  9. char* nowa=new tab[a+3];
  10. char* pocz=nowa; // wskaźnik na początek tego łańcucha, bo w whilezwiększamy wskaźnik i nie można go noralnie zwrocic
  11. while(*tab) //alternatywa od tego while to strcpy(nowa, tab);
  12. {
  13. *nowa=*tab;
  14. nowa++;
  15. tab++;
  16. }
  17. for(int i=0; i<3; i++)
  18. {
  19. *nowa='!';
  20. nowa++;
  21. }
  22. return pocz;
  23. }
  24.  
  25. int main()
  26. {
  27.  
  28. char tab[]="funkcja";
  29. cout<<funkcja(tab);
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement