Results 1 to 3 of 3

Thread: initializing an array

  1. #1

    Thread Starter
    Ya ya Baby!!!Me is Back
    Join Date
    Jul 2002
    Posts
    362

    initializing an array

    I have an array that I know the size because of a calcul. Something like : iSize = x-y; char c1[iSize];

    But I have that error :expected constant expression

  2. #2

    Thread Starter
    Ya ya Baby!!!Me is Back
    Join Date
    Jul 2002
    Posts
    362
    I can't initialize an array with code like that ?

  3. #3
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    You can't do that in C/C++
    I personally like link lists for problems like this.

    But if you want to continue to use arrays you have to use pointers and use new to create a new array to your size and delete to destroy it when you are done with it.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width