Converting an "ASCII decimal" to an integer in C
An answer to this question on Stack Overflow.
Question
I am trying to convert an "ASCII decimal" to an integer. The "ASCII decimal" can be up to 10 digits long and is padded with spaces if there are no more digits (ie 36________, where the "_" is actually space). I am really new to C (I just started learning last week) and I have absolutely no clue how to do so.
For example:
int main(int argc, char *argv[])
{
int fda = open(argv[2], O_RDONLY);
char arSize[10];
read(fd, arSize, 10);
//convert arSize to an int and store in i
lseek(archive, i, SEEK_CUR);
}
Answer
Since you seem to be opening a file, you may also find fscanf helpful.