Блог пользователя redc

Автор redc, история, 4 года назад, По-английски

May you explain to me ?

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

They're the same thing. You might often see people do signed main instead of int main because they do in the beginning. #define int long long

This is beacuse long long is not allowed as a return type in main(), but people want to use int instead of long long as they are used to it.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

It is mainly in competitive programming when programmers replace int with long long in whole code with #define int long long. But main allow only return type of 32 bit but long long is 64 bits. So to keep return 32 bits signed is used because signed int and signed are same, but writing signed does not replace anything. If you write signed int then it will throw error as int will be replaced.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    Interesting decision to bump an old post like this that already has an adequate answer.

    I guess to make it worth people's while, I'll add in a fun fact of my own for the people who got summoned to this post by the comment above: when using g++, you can technically omit the return type entirely and it will still compile (with a warning about how ISO C++ forbids omitting the type). That is, main() {} is sufficient. Use at your own risk.