I need to know a bit about this "default int" thing in C. What I mean is, is this actually ok and with what version of C is it ok?

main()
{

return 0;
}

As far as I knew this was standard modern C (i.e., no retarded default-int)

int main()
{
return 0;
}

Your first code snippet is not acceptable on any standard version of C. However some old compilers, probably Turbo C, might accept it. C and C++ languages both require main() to always return int.

I need to know a bit about this "default int" thing in C. What I mean is, is this actually ok and with what version of C is it ok?

I guess my question would be "why?" If you know int main() will always work, why would you need to know when "default int" is OK? In other words, if you know A sometimes works but not always, and B always works, why understand A? Just ignore it.

I'm not going to use it, I was just taking the "C programming" skills test on oDesk, and it always uses "void main()" or "main()" and it's god-awful garbage code on the test the whole way through.

I still plan to use oDesk though because the testing thing is at least a nice idea.

I'm not going to use it, I was just taking the "C programming" skills test on oDesk, and it always uses "void main()" or "main()" and it's god-awful garbage code on the test the whole way through.

I still plan to use oDesk though because the testing thing is at least a nice idea.

Sorry, but that sounds stupid. If you want to increase you skills, why use something that doesn't have the skills you need? Would you ask your little brother to check your calculus homework? Would you ask an armless man to teach you to shoot baskets? Would you ask a blind man to teach you to draw?

Garbage code is garbage code. What positive things can you actually learn from it? You're fighting the learning process all the way.

Sorry, but that sounds stupid. If you want to increase you skills, why use something that doesn't have the skills you need? Would you ask your little brother to check your calculus homework? Would you ask an armless man to teach you to shoot baskets? Would you ask a blind man to teach you to draw?

Garbage code is garbage code. What positive things can you actually learn from it? You're fighting the learning process all the way.

The intention was purely to add some small amount of credibility to my profile, I assure you.

I need to know a bit about this "default int" thing in C. What I mean is, is this actually ok and with what version of C is it ok?

main()
{

return 0;
}

As far as I knew this was standard modern C (i.e., no retarded default-int)

int main()
{
return 0;
}

Implicit int was standard prior to C99. Since C95 is still the de facto standard, the first definition of main is still accepted in C circles, but considered bad practice. If you write code that needs to be compatible with C++ or C99, or want your code to be future proof and good style, avoid implicit int.

Comments
Thanks.
This article has been dead for over six months. Start a new discussion instead.