-1

Why people do not deallocate c-style strings?

const char* string = "Whatever";

And how does it work actually, because there is no some kind of new or malloc?

Kasata Ata
  • 365
  • 3
  • 11

1 Answers1

2

For the given string there is no memory allocation on the heap.

An array of chars "Whatever" is created in the const section. The address of this array is given to the pointer string

Rishikesh Raje
  • 8,556
  • 2
  • 16
  • 31