Can someone please tell my why the following won't compile?
}
void main()
{
I'm pulling my hair out!
Kevin
Can someone please tell my why the following won't compile?
}
void main()
{
I'm pulling my hair out!
Kevin
This is the error I get:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
c:\programs\cpp1.cpp(3) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Cpp1.exe - 1 error(s), 0 warning(s)
}
void main()
{
why are you trying to compile something that does nothing?
either way it must return int not void so it would be like this
int main()
{
}
why are you trying to compile something that does nothing?
either way it must return int not void so it would be like this
int main() { }
The following worked:
void main()
{
}
Is something wrong with my software, or something?
int main() {} should work fine.
void main() {} should also be accepted even though it's not good practice.
Your initial code is either posted incomplete or is way wrong.
>Is something wrong with my software, or something?
Sure, blame the software for your misunderstanding of the language.
>void main() {} should also be accepted even though it's not good practice.
You should start telling people that it's WRONG. That way they may actually stop using it. The official rules do allow for loopholes where void main is legal, but otherwise it's undefined, and undefined behavior isn't just "not good practice", it's a serious problem.
true. I meant "the compiler will accept it" :)
Just like the compiler will accept you to write code that writes outside its memory space but doesn't shield you from the consequences.
what?????????????????????????????
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.