I have a String for example "23:0" which is a hour format. I need to convert this to a int so I can add time to it for example. I have a string "23:0" I need to add 6 hours which would be "6:0" which would then give me "5:0", and then convert this back to a string.
Any ideas would be greatly appreciated :)
When I write my function I get an error "cannot convert 'string to char*' in initiliazation" my function looks like this:
int convert(String x){
char *str = x;
int hour; int minute;
sscanf(str, "%d:%d", &hour, &minute);
return hour;
}
convert(time) //time is a String for example 23:0
strptime()to convert from string to time andstrftime()to convert from time to string. However, it might be overkill for just hours and minutes.