/* Project1 by Jason Plumb

   This program will scan in an arbitrary string of characters and will convert
   it to an integer.  It will add one to the integer and will display the
   result.  If no command line parameters are given, the program will prompt for the
   input string.  If one parameter is given, the program will assume that this parameter
   is the input string and will bypass input prompting.  As an added bonus, the user
   can specify a second command line parameter to indicate the base of the input number.
   It should be noted that if a base is specified, the program does not perform error
   checking and the output is undefined.  It should also be noted that the program uses
   a long integer value, and thus the input number represented in the input string
   should be in the range -2,147,483,648 to 2,147,483,646.  Any number in this range
   should be handled properly, although the output for numbers outside this range is

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
 char buffer[100], *pTemp;
 int iBase;
 long iValue;

 iBase = 10;                                          // Assume 10 to be default number base
 if(argc==1){                                         // If no command line params given
    printf("Enter number to be scanned:  ");
 else if(argc>=2){                                    // If one param given
    sprintf(buffer, "%s", argv[1]);                   // Copy to buffer
    if(argc>2){                                       // If at least 2 params given
       iBase = atoi(argv[2]);                         // Take 2nd one to be the base
 }//else if
 iValue = strtol(buffer, &pTemp, iBase);              // Do the conversion

 printf("You entered \"%s\"\n", buffer);
 printf("In base 10, this number is %d\n", iValue);
 iValue++;                                            // Increment result by 1
 printf("Your number + 1 is:  %ld", iValue);

 return 0;