I dynamicly allocated char array with lenght of 30. Then I put x characters int it. Then i dynamicly allocated new char array with lenght of x. I transfered characters from old to new array and when I wanted to print out new array, it printed to me characters from old array as I excepted, and some other unknown characters(like dash). I don't see where is the trouble so I am asking you to help.
Here is the code:
#include <iostream>
cout outputs all the character till it find a '\0'
however you are not copying that character (you don't even reserve the space)
So when you try to output it goes out of bounds.
This shouldn't change anything, since '\0' has an ascii value of 0, but when you're making a end-of-string test, you should compare the character to '\0' (the end-of-string character), not to 0. So, it should be while(unos[x]!='\0')
As well, as is, your for loop isn't including the end-of-string character. In the example given (abcd), the do-while-loop will end when x=4. Thus, the for-loop will NOT run when a=4. And so, your ispis array will be ['a''b''c''d'] without the end-of-string character, when it SHOULD be ['a''b''c''d''\0'].
So, changing the for-loop to for(int a=0;a<x+1;a++) should fix it.