c - Allocate array from command line parameters -


I am working on a small application and I am capturing a value from the command line. I would like to capture the value and use it to initialize an array. Here's what I'm trying to do.

  int main (int argc, char * argv []) {int option = atoi (argv [2]); Int value [options]; ......}  

I am getting a compilation because my option variable is not a const error: error 2 error C2057: continuous expression of hope

Is there any way I can do that?

Thank you for your help!

itemprop = "text">

If compilation is not known at the time, then you need to allocate memory to dynamic, Code> malloc :

  int main (int argc, char * argv []) {int option = atoi (argv [2]); Int * value = Molok (option * sizeof (int)); / * ...... * / free (value); / * Removing memory when you are done with it * /}  

Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -