c++ beginning with codeblocks

I've just installed codeblocks and I tried to build my first c++ program just to display two words. as a result I've got: fatal error: no such file or directory.
can I get help to fix this problem.
frank
Well, post some code.
closed account (LzwkoG1T)
Look up a tutorial on basics of c++. Or use this site itself.
But a basic program to print stuff:

1
2
3
4
5
6
7
8
9
#include<iostream>

using namespace std;

void main()
{
    cout << " Your text here ";
    cin.ignore();
}
closed account (jwkNwA7f)
@ASI7296 Although it will work, main() should always return an int. When you do int main(), it will automatically return 0, or you can type return 0; out yourself.
closed account (LzwkoG1T)
that's only necessary on some compilers right? not on all (I think.)
closed account (jwkNwA7f)
@ASI729g I don't know much about why it is not a good idea. I have heatd it said by a lot people. It should still work on most compilers
I don't know much about why it is not a good idea

It is bad because the C++ Standard (the "contract" by which all C++ compilers must conform) says that main must return an int. Stroustrup's FAQ:

http://www.stroustrup.com/bs_faq2.html#void-main
closed account (LzwkoG1T)
Thank you for the info :)
void main() is acceptable in C, I believe.
void main() is acceptable in C, I believe.

I again refer to Stroustrup's FAQ:

http://www.stroustrup.com/bs_faq2.html#void-main

The definition

void main() { /* ... */ }

is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1.
Oh, I must have been working off outdated information. I learned that the implementation may allow the syntax void main(), but it still returns an int somehow.
closed account (Dy7SLyTq)
no i dont think void main returns an int. it is not allowed in c/c++ by the standard but certain compilers (it might be all... i havent tested it) allow you to return nothing. its frowned upon, but it will "work"
I meant like I read somewhere that the C standard allows the void syntax as long as the compilers still have main() return an int. I wish I could find that page.
closed account (Dy7SLyTq)
that doesnt make any sense. c does not allow void at all by the standard. and if you have void main it wont return an int, once again that wouldnt make any sense
For safety's sake, just return an int :D
Topic archived. No new replies allowed.