command line argument help
Code:
//detab - replace tabs with appropriate number of blank spaces to reach next
//tabstop. Assume a fixed number of tabstops.
#include <stdio.h>
#define MAXLINE 81
int gotline(char s[],int lim);
int main(int argc,char argv[]){
//int len; /* length of current line */
//int getmore = 0;
int tabstops = (argv[1] - '0'); //here is the line in question
//char line[MAXLINE]; /* current line being read */
printf("%d\n",tabstops);
getchar();
return 0;
}
/*int gotline(char s[],int lim){
int c,i;
for(i=0;i < lim-1 && (c = getchar()) != EOF && c != '\n';++i)
s[i] = c;
if(c == '\n'){
s[i] = c;
++i;
}
else if(c == EOF && i > 0){
s[i] = '\n';
++i;
}
s[i] = '\0';
return i;
}*/
commented code is not the problem... I'm trying to learn how to convert an interger entered on the command line as an argument from a char pointer to an integer data type of the same respective value, (ie argv[1] is a char pointer to an integer, say 14, and I would like to place the value "14" into "tabstops"