Need some help. What is the difference between using “int main()”, “signed main()” and “int32_t main()” in C++?
signed
is a synonym for int
, so:
int main()
and
signed main()
are the same, though the latter would be very unconventional and you’d better have a good reason for using it.
int32_t
will often - but not always - be an int
(it’s implementation-defined whether they are equivalent), so
int32_t main()
would be both very unconventional and possibly illegal.
woaahh…seeing you after a looooong time😃
Thanks a lot for this!!
Also, people generally use the macro #define int long long
(it’s highly not recommended). Here they cannot write int main()
, as it gives a compilation error main should return an integer value
. So they choose to use signed main()
or int32_t main()
The second comment in this is beautiful xD.
The one from UndeadFish?
Someone really needs to make a “Professional Programmers React To CP Code!!” video at some point XD
Yess! That one.
This would be so much fun xD.
But why?
Using long long for every single variable might result in TLE. (Rarely, but it happens). Operations with long long data type takes more time.
Also, it’s good to know where in your code you need long long. With a couple of submissions getting WA because of overflows, you’ll know where exactly to use long long in your subsequent codes.
Gotcha. . . Great points. Thanks
awesome explanation
Nicely explained
Thanks ,that what I want to know …