Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to create array dynamically in c++ ?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am doing a simple stuff

code in main


i just want to create an array dynamically after taking the value from user, how to do that , in simple manner , i am using turboC, because i am doing some computer graphics & my colg told me to use TurboC
can any one help me solve my problem ?
thanks
 
Jason Reaves
Greenhorn
Posts: 3
C++ Linux Monad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Std C++ wants the array size to be a constant so it's known at compile time. If you need dynamic memory you can do something like.

Alternatively you can look into vectors which allow you to use it as a dynamic array.
c++ reference <vector>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic