Why to write int(in_time.ti_hour) ?

cout<<"Park-in time: "<<int(in_time.ti_hour)<<":"<<int(in_time.ti_min)<<":"<<int(in_time.ti_sec);



Why I have to write int(in_tie.ti_hour) can't I just write in_time.ti_hour .
Without knowing the types of anything, your code is meaningless.
Last edited on
Is ti_hour a char type (char, unsigned char or signed char)? The problem is that C++ doesn't have different types for characters and integers. char is actually an integer type of size 1 byte, but char is often used to store characters so the << overload for char will assume you want to print a character. By casting the variable to an int you get the int overload of << which will print the value as an integer.
Last edited on
Topic archived. No new replies allowed.