Dude a standalone source file works fine.
What are you talking about?
Lol![]()
a lot of ebook links can be found
at http:/eboook.webs.com open the site and
click the tutorial link
Would a part II be popular?
http://logickills.org
Science - Math - Hacking - Tech
I am new in C so it might be very helpful. Great job!
Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!
nice tutorial I found it useful
I am new to codecall and am trying to learn C++ as a first language for programming, and i had a few question on your code. (4 actually)
when you use int main(void) what is the difference between using () and (something here)
because i have seen it both ways. and also i know that within the {} brackets int means
integer and does the term integer also apply in this situation?
when using the printf function (its a function right?) couldn't you just use "cout" because i thought it did pretty much the same thing. Is there a difference?
with the return(0) could you use any other number in between the parenthesis or does
it even make a difference?
Pertaining to using semicolons in C++ i understand that you have to use them at the end of statements. What exactly is a statement? Sometimes my compiler (Dev-C++) will
tell me that there was an expected semicolon before a function like "cout" or "endl".
If you could clarify any of these questions i would appreciate it greatly. I'm sorry for asking so many questions but i'm just trying to learn the C++ language as thoroughly as possible
cheers, will
EDIT - sorry i forgot to tell you that you did a great job on your tut. it clarified the #include(s) for me and showed me some different ways to do things. A part II would be nice too : )
Last edited by will38; 07-30-2009 at 08:29 PM. Reason: forgot something
I don't know how active the author of this tutorial is ATM, so I'll just give my answer.. Might also be better to start a new thread if you have questions? Anyway...
1) When you have "something" within the () after int main, this "something" contains the command line options that are passed to your program at startup. Unless you want to use these options, you can just write int main() or int main(void).
argc is the number of command line arguments (including the first one being path to executable), the argv parameter is an array of character arrays (strings) which contains the command line arguments.Code:int main (int argc, char* argv[])
2) Yes, the integer also applies in this situation. Main is also a function, int is the return value from the function. In other words, main returns an int (integer).
3) Cout and printf are not identical, though they are often used for the same things. The thing here is that this tutorial is a C tutorial, while cout is a C++ function (not available in C).
4) The return statement specifies which value will be returned from the function. As I said above, the "int" tells us that main returns an int. The return value is passed to the operating system. What the operating system chooses to do with it might vary, but generally return(0) means success, while a different value means failure. So if your main function completed successfully you would return a 0, while if you encounter an error you might want to return e.g. 1.
5) Dev-C++ is not a compiler :S It's an IDE.. Anyway, defining a statement can be a bit hard.. I advise you to pick up a book on C, or just study examples. I don't feel like going through all the syntax here...![]()
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
int main() accepts no command-line parameters.
int main(int argc, char* argv[]) accepts command-line parameters.
cout does not exist in C, only in C++.
return 0 indicates successful execution. Other return values would indicate a failure and the nature of it.
The precise definition of what counts as a statement is a little... complicated. It takes about a page in Bjarne Stroustrup's The C++ Programming Language.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks