mercredi 21 décembre 2016

Store the command line input into an array

Here is the problem: I have input given from the command line as

 5 1 2 3 4 0
 5 3 5 7 8 5

I need to store the input integer values in an array. The first element always tells the length of the array. So my question is how do you take the inputs from the command line and store it into an array.

Taking the input values as strings and parsing them for the int's is the solution that I could come with. Is there any other efficient way to do this. One other solution that I could think of is using the argv for the first array but not sure about the second one.

Aucun commentaire:

Enregistrer un commentaire