Define a structure like this:
typedef struct {char *s;
int k;}mystruct;
main(){
mystruct str1,str2;
// fill str1...
...
str2=str1;
Now if one changes a character in the string s
in str1, this is also changed in str2, but does this really leak memory? I do not see any memory problems unless there is a delete, which cannot really be done, since s
is effectively an array, or am I missing something?
Also, it looks to me like the declared dimension of s should be specified somewhere, s will be using a contiguous space on
the stack and the compiler cannot reserve ALL space for s,
or am I wrong?