I have data in my .txt file containing different time ins and time outs of employees. For example, 10:20
but I initially designed the structure to have their data types to be of char arrays or string. Since I'll be using the time values in another function, I have to use the atoi() function to convert them into integer values. Problem is, there is a colon :
in each of the time values. Would it be possible to convert the string 10:20
to an integer using atoi() so that I can it in my future functions? Does the use of atoi() allow some splitting or some sort so that I can convert my time value from string to int?
I tried
char time[10] = "10:20";
int val;
printf("string val = %s, int value = %d", time, atoi(time));
But my output is only
string val = 10:20, int value = 10
so only the string before the :
is read and converted to string. I would want that after converting, I would stil have 10:20 as the result but in integer because I am going to use relational operators with it.