I need to read args given by the user. They would type something like ./main -3 word1 word2 word3...
and so forth.
I need a way to parse the first argument given to determine if it's an integer or not. If it is then I need to snag that integer. Here is the code I have worked up thus far.
#include <stdio.h>
int main(int b, char** locations) {
char determine = locations[1];
return 0;
}
As far as I understand strtok()
picks apart a string by an argument you give it. For example you can remove the space from a string that you know contains a string.
The problem is that in my situation the user can either enter a number or enter no number and I need to differentiate whether the first argument given is an integer or not. If it is then I need to be able to obtain the integer as a variable.
One thing that helps me though is that if the user is going to enter an integer then they have to use a -
in front of it.