Problem with strtok

Hi, I have problem. I need to printf how long is one company opened. Data is in txt file. For example I got company A and it is opened M-F 11-19 (monday to friday) I need to printf that this company is opened 8 hours.

Got any ideas? :)
What is the general format of such string?
Last edited on
int hours(char*);
closed account (o3hC5Di1)
I think Mr. Vlad meant, is the format of the opening hours always
[1 letter]-[1letter] [number]-[number] ?

If that is the case, you can use the scanf() function to assign the numbers to integer variables, after which you can make calculations with them.

See http://www.cplusplus.com/reference/clibrary/cstdio/scanf/ for more information on how to do so.

Hope that helps.

All the best,
NwN
Last edited on
Topic archived. No new replies allowed.