Difference between "int main() ", "signed main()" and"int 32_t main()" in C++?

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.

4 Likes

woaahh…seeing you after a looooong time😃

4 Likes

Thanks a lot for this!!

1 Like

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()

8 Likes

The second comment in this is beautiful xD.

3 Likes

The one from UndeadFish?

Someone really needs to make a “Professional Programmers React To CP Code!!” video at some point XD

5 Likes

Yess! That one.

This would be so much fun xD.

2 Likes

mirko’s comment is pretty good, too :slight_smile:

3 Likes

Welcome back @ssjgz! Seeing you here after a long time. :slight_smile:

3 Likes

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.

5 Likes

Gotcha. . . Great points. Thanks

1 Like