char time[] = "1:27"; char *s1 = time; char *savept = NULL; int hour = atoi(strtok_r(s1, ":", &savept)); int min = atoi(strtok_r(s1, ":", &savept)); int total = hour + min; printf("Hour is: %i\nMinute is: %i\nTotal is: %i\n", total );