Difference between int main() and signed main()

signed main()
{
  ....
}

int main()
{
  ....
}
int main()

is the idiomatic declaration of main in C and C++.

signed main()

is the hoop you have to jump through to get compilable code if you do something naughty like

#define int long long

(with the above #define in place, the expansion of int main() would be long long main(), which is illegal in C and C++).

See some of the posts in this thread.

Edit2:

Oh - there’s a whole stackoverflow thread with almost the same title :slight_smile:

2 Likes

But, if you don’t do anything naughty, the difference turns out to be nothing but a social construct. :stuck_out_tongue_closed_eyes:

1 Like