CString array problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rag84dec
    New Member
    • Mar 2007
    • 100

    CString array problem

    Hi,
    i am using the CString array to hold some values...
    Is it right to do this..
    CString t[]=new CString[];
    But i am getting errors...
    Please help...
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by rag84dec
    Hi,
    i am using the CString array to hold some values...
    Is it right to do this..
    CString t[]=new CString[];
    But i am getting errors...
    Please help...
    Can you write those errors here?

    Regards

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Originally posted by rag84dec
      CString t[]=new CString[];
      This syntax: CString t[] creates an array. t is the address of element 0.
      This syntax: new CString[] allocates memory and returns a CString* to element 0.

      You cannot assign an address to the address of a local variable. Doing so would allow you to change the address of the local variable.

      The correct syntax is:
      [code=cpp]
      CString* t=new CString[];
      [/code]

      Comment

      Working...