Discussion:
memory info lost?
Add Reply
jak
2017-05-05 15:38:21 UTC
Reply
Permalink
Raw Message
Hello everybody. One question: If we have:

char str[] = "\0\0\0\0";

We can know the amount of memory in this way:

int dim = sizeof(str); /* 5 */

but if we have:

char *ptr = "\0\0\0\0";

Do you know a way to know how much memory occupies the initialization
string?

thank you in advance
Richard Heathfield
2017-05-05 15:44:25 UTC
Reply
Permalink
Raw Message
Post by jak
char str[] = "\0\0\0\0";
int dim = sizeof(str); /* 5 */
char *ptr = "\0\0\0\0";
Do you know a way to know how much memory occupies the initialization
string?
Given the code as written, there is no way to retrieve that information
in standard C.
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
Loading...