0

char *s; s=new char[30]; Question in the description.

I was wondering how would compiler see this. We declared a character pointer first. And then we declared the memory space the pointer is going to be targeting upon (If I am not wrong). But what if the value of the string 's' is less than 30, then what happens to the rest of the memory?

11th Jun 2020, 12:28 AM
Prashant Pant
Prashant Pant - avatar
2 ответов
+ 3
The pointer definition must be done before assigning something to it. The rest of the memory is wasted for the variables lifetime.
11th Jun 2020, 3:20 AM
Sandra Meyer
Sandra Meyer - avatar
0
Sandra Meyer is there a way to release it?
11th Jun 2020, 5:32 AM
Prashant Pant
Prashant Pant - avatar