For 'duration' I used the following which works (at least within a testing file), using atoi on individual parts of the inputted string fraction s:
double n = atoi(&s[0]);
double d = atoi(&s[2]);
int duration = ((n/d))/(.125);
return duration;
I added the &
after trial and error, and as a result I have a few questions on how atoi works:
1) In Caesar I used: int key = atoi(argv[1]);
which worked well, and converted the whole string in one go. In the case of the fraction, does atoi NOT work because it returns a NULL value when it hits the /
character?
2) What exactly is the &
doing in the code above? From reading, it looks like & is an "Address of Operator" - meaning the & pointing to the value that is stored in the s[0] location...but isn't that what writing s[0] is already doing?