I am getting segmentation faults when trying to read command line arguments char-by-char.
I have the following code:
int main(int argc, char** argv)
{
int i,j;
for(i=1;i<argc;i++)
{
for(j=0;argv[i][j]!=0;j++)
{
printf("%c",argv[i][j]);
}
//printf("%c",argv[i][0]);
}
}
This code runs, but when I uncomment the line printf("%c",argv[i][0]); I get a segmentation fault.
Why exactly is this considered access to unallocated memory and how am I supposed to parse command line arguments without checking their content?
Specifically, I want to know if the argument is of the form: <+->e<0-9A-F> meaning plus or minus followed by 'e' followed by a single hex digit. How would one go about this in c?