I'm Trying to write a code that will initialize an array of pointers with default size of 5 and with the option of passing a number argument (in octal representation) to the program that will tell the size of the array the user wants. I'm having trouble figuring out how to get the number in string form from argv and then converting it to a number and initializing the array with this size. Can someone please show me how to do this?
Asked
Active
Viewed 98 times
0
-
1What did you try, which part do you have a problem with. Did you break it into steps? Can you access the argument? Can you convert a string to a number? Can you allocate an array? Is it 32 or 64 bit? Which OS? Please tag. – Jester May 05 '21 at 13:11
-
1How to access command line arguments depends on your OS, your architecture (32 or 64 bit), and the structure of your program (entry at `_start` or `main`). Please tell us more about your environment. – Nate Eldredge May 05 '21 at 13:16
-
Octal is about the same as [NASM Assembly convert input to integer?](https://stackoverflow.com/a/49548057), except you simply multiply by 8 instead of 10. (So it only takes one LEA to do `total = digit + total*8`) – Peter Cordes May 05 '21 at 13:56