If you want MFC you will have to get a compiler from microsoft.
If you want MFC you will have to get a compiler from microsoft.
STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.
Aren't MFCs VERY good for programming? Or is it better if I do it myself and learn the functions of it?
That is not something I know, I havent messed much with Win32 API nor with MFC.
STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.
Jesus no wonder I was so confused. Is this standard notation? What's with the " (int argc, char *argv[])"?Code:#include <iostream> using namespace std; int main (int argc, char *argv[]) { cout << "Hello World!" << endl; cout << "Press ENTER to continue..." << endl; cin.get(); return 0; }
yah, its standard. that argc and argv is used for commandline parameters, check the faq or search for more info.
STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.
I liked it better the other way lol. It was way easier.
The "(int argc, char *argv[])" is for receiving arguments from the command line. So if you execute your program like this
Those variables areCode:C:\>program
Whereas if you execute your program like thisCode:argc: 1 argv: "program" NULL
The variables areCode:C:\>program arg1 arg2 hippo
It's useful for options and stuff.Code:argc: 4 argv: "program" "arg1" "arg2" "hippo" NULL
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
There is no need for the parameters to main if you do not make use of them. Both of the following are standard (and nothing else is):
Code:int main( ) { ... } int main(int argc, char* argv[]) { ... }
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
I'm wondering why use that code if you can do this:
Code:#include <iostream> using namespace std int main() { cout << "This is much easier and produces the same results" << endl; }
<iostream.h> was never part of the C++ standard. It is not deprecated. It doesn't even work at all on modern compilers (including Microsoft's most recent versions). It works on VC++ 6 because that version was created at the same time as the standard and because legacy code from before the standard had to be supported. The standard header (<iostream>) works on VC++ 6 also, so there is no reason to use the old, non-standard header.
The two forms of main specified by Zach L. are standard. There can be other forms, but they all must specify int as the return value. Again, VC++ 6 is just one compiler that happens to allow void main. Other more standards compliant compilers will not allow it. Why not use the one that works almost anywhere.
Even though main must specify int as its return value, there is a special case for the main function that says that if you don't return a value, then 0 will be returned automatically. VC++ 6 gives a warning if you don't return something, but modern compilers allowas a legal program.Code:int main() { }
VC++ is a good IDE, but I believe Dev-C++ and the Beta VC++ 2005 are both free and one of them is probably better given that they use much more standards-compliant compilers. If you have money, there are several compilers, including VC++ 7.1 (2003) that are better than version 6.
The namespace was introduced to avoid naming conflicts. For small beginner programs the using namespace std; is fine. However, that basically nullifies the entire reason behind the feature that was created for the language. Read up on namespaces to find out why they are useful, and then decide if you want to take advantage of their benefits or if using the easy way is enough for you.
Last edited by Daved; 07-23-2005 at 09:11 PM.
Okay just a checkup. It allows for two variables to have the same name. Example:
Have I got it right? Maybe?Code:namespace int foo int foo //another variable, same name
Yes, that's the idea, although that isn't C++ syntax.Code:#include <iostream> #include <string> namespace foo { const int count = 100; } namespace bar { const std::string count = "Dracula"; } int main() { std::cout << foo::count << " " << bar::count << std::endl; }
My first post on this forum, and it wasnt even a question lol. Thanks you answered my question before i could answer it.
Thanks