int main() {
char *time = (char *)malloc(10240 * sizeof(char));
int i = 0;
scanf("%s", time);
i = atoi(time);
if (time[8] == 'P')
i += (i != 12) ? 12 : 0;
else
i += (i != 12) ? 0 : -12;
printf("%02d%.6s\n", i, time + 2);
return 0;
}
I'm new to C programming language! I got this code from HackerRank! This is code for convert 12Hour time to 24Hour time.
Can anyone please explain this part: i += (i != 12) ? 0 : -12