I have a nice big problem, that I've happily minimized down to a little problem. Unfortunately, my little problem is the area which I always struggle with, and help would be much appreciated to help me understand (because providing an answer is one thing, explaining why provides learning!).
I have a long number in argv[3], and I need to take out a sequence of digits from the start of this number. (ie. The number is 943209432, and I want just the first three digits, 943, in one int). I'm well aware that argv[] stuff is just a pointer to a string, and by using atoi() or atof() you can convert it to a number.
To take out the first few numbers however I was planning to use argv[3][k], where k gets larger depending on how many numbers I need. Due to my lack of knowledge of pointers and such (or even if this is a pointer now that it's changed) I can't change it into a number.
If that makes no sense, here's my little snippit of code:
1 2
|
int num100;
num100 = atoi(argv[3][k]);
|
To me, it seems that that should work, but I am sadly disappointed when errors occur when I compile...
Where have I gone wrong, and why? All I want is a nice little digit between 0 and 9...
Thanks heaps for reading so far, even if you aren't sure of the best way to answer what feels to me like a simple question...