Re: memory leakage problem




chets wrote:
Hi all
Can anyone tell me what is the difference between:-

*p=q; and p=&q; in C

where declaration is like this
char **p;
char *q;

*p=q; means: Take what p points to and set it equal to the current
value of the variable q.

For this to work, 'p' must point to a valid 'char *'. Otherwise,
changing the contents of what 'p' points to can lead to a crash. (And
if you haven't assigned a value to 'q', what value you put in is
undefined.)

p=&q; mean: Set p equal to the address of the variable q.

This has no special requirements. Since you declared 'p', it exists and
storage has been allocated for it, and of course 'q' always has an
address.

DS

.



Relevant Pages

  • Re: MFC dll and exe porting to 64-bit
    ... Why the obsolete 'char *' instead of the proper LPTSTR? ... We are no longer programming 16-bit windows in an 8-bit character world, ... string arguments should probably be LPCTSTR, that is, const parameters. ... declaration of the function itself, in context (meaning show the surrounding class ...
    (microsoft.public.vc.mfc)
  • Re: malloc warning gcc > 4.0
    ... > char* p; ... > warning: incompatible implicit declaration of built-in function 'malloc' ...
    (comp.lang.c.moderated)
  • Re: Access one character in an array of characters
    ... enum Suit; ... Without seeing the exact declaration of ClubArray I cannot be certain, ... but you have probably declared it as a C-style string, ... confusion between a string and a vector of char. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: MFC dll and exe porting to 64-bit
    ... Why the obsolete 'char *' instead of the proper LPTSTR? ... We are no longer programming 16-bit windows in an 8-bit character world, ... INT_PTR nResponse = dlg.DoModal(sDsn, lpszDriver, fRequest, szResPath); ... declaration of the function itself, in context (meaning show the surrounding class ...
    (microsoft.public.vc.mfc)
  • Re: pointer assignments
    ... chets wrote: ... where declaration is like this ... char **p; ... possibly being used by some other thing (possibly the stack, or malloc ...
    (comp.unix.aix)