Question: I am assuming I am using this the wrong way, but the idea is for the command line argument to be the length of my fibonnaci serquence... however the way I am doing this, after 9 I am screwed... how can I resolve this issue?

```
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* for fork */
#include <sys/types.h> /* for pid_t */
#include <sys/wait.h> /* for wait */
int fibonacci(int n)
{
  int first = 0;
  int second = 1;
  int total, i;
  for (i=0;i<n;i++)
  {
    printf("%d\n", first);
    total = first + second;
    first = second;
    second = total;
  }
  return 0;
}
int main(int argc, char *argv[])
{
    /*Spawn a child to run the program.*/
    pid_t pid=fork();
    if (pid==0) { /* child process */
        if(*argv[1] == 45){
            printf("number invalid \n");
        }else{
            int number = *argv[1] - 48;
            fibonacci(number);
        }
    }
    else { /* pid!=0; parent process */
        waitpid(pid,0,0); /* wait for child to exit */
    }
    return 0;
}

```

Answer: 
You should parse the command line argument using `strtol`, or similar, for example

```
number = strtol(argv[1],NULL,0);
/* last parameter gives the base, 0 detects hexadecimal (0x) and octal, defaults to 10 */

```

if you want to skip error checking. Cleaner, with error checking:

```
char *end;
number = strtol(argv[1],end,0);
if (end == argv[1])
{
    /* no valid digits */
    exit(EXIT_FAILURE);
}
if (*end)
{
    /* not all of argv[1] has been consumed
     * handle errors
     */
}
/* full parse of argv[1], no problems, carry on */

```
Try using the function `atoi`.