>Lack of a standard to conform to?
Pfft. That's not a valid excuse. No-one set any standards for me, and look at me now!
>Lack of a standard to conform to?
Pfft. That's not a valid excuse. No-one set any standards for me, and look at me now!
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
>and look at me now!
You don't really want me to comment on that, do you?
My best code is written with the delete key.
>...she says after writing a rather long explanation of stuff dealing with binary trees. Are you saying that it's OK to get it in ~4 years?
I don't think that was the point she was trying to get across.
>Pfft. That's not a valid excuse. No-one set any standards for me, and look at me now!
Without standards, your code doesn't conform to everyone elses. Thus, your code cannot be easily joined by the numerous other programs developed from the standard. Hint:Your doing more work then you need to. There is a reason for standards, it keeps things clean and easy.
OS: Windows XP Pro CE
IDE: VS .NET 2002
Preferred Language: C++.
Originally posted by Death_Wraith
#5
this isn't needed, BUT, its good coding style.Code:int main(int argc, char* argv[] )
What exactly is that and why is it good style? I always just delete it when the compiler adds it in heh.
Regards,
~Joshua Norton
>What exactly is that
Arguments to main that allow you to take command line input from the program invocation.
>why is it good style?
If you don't use command line arguments then adding unnecessary clutter is bad style. You're also more likely to not get a clean compile if the compiler warns about unused variables.
My best code is written with the delete key.
If you don't understand what Prelude just said, this is a bit of a more detailed explenation.
Basically, main() is a function, and it can take various parameters like any other function. The parameters it can take are known as 'argc' of an int type, and '*argv[]', which is an array of char type(notice asteriks), this can take array elements of strings. 'argc' of an int type, is equal to the number of elements in '*argv[]'.
The first element in '*argv[]' is the filename of the source if I remember right. Then any other corresponding element in the array is whatever argument you pass to main() from the program invokator.
The program invokator, is the operating system alot of the time. So lets say you go into 'run' on a windows machine, and type in 'programname /?'.
'/?' is the argument that is passed into main() as *argv[1]. You can deal with arguments like any other function really. As an example:
Note that the program invokator is not limited to the operating system, and that 'argc' and '*argv[]' can be renamed to whatever you prefer.Code:int main(int argc, int *argv[]) { for (int x = 0; x < argc; x++) { if (argv[i] == "/?") //Handle argument here. return 0; }
OS: Windows XP Pro CE
IDE: VS .NET 2002
Preferred Language: C++.
Yeah I know that but I found Death_Wraith explaining line by line the code.. so i said thatOriginally posted by Prelude
That sounds like what we've been doing all along. You just have to wade through the dozen side conversations (that are all very interesting...sometimes) to find it.
Well I touched upon most of the arguments stated in this post.
#1 the include line
#2 the using namespace std;
#3 return 0;
#4 argc, int *argv[]
#5 etc...
<<Yeah I know that but I found Death_Wraith explaining line by line the code.. so i said that
I just pretty much summed up the whole post. Trying to make life easier!
ok i got the program working by copy and pasting sircrono6 code. but sircrono6 you asked me " am i coping the code properly" i assure you i have and the only reason your code worked is that you added 2 more lines to the bottom of the code. why does this fix the problem and why isnt it in tutorial then? how am i suppose to learn when its not even a full code. thanks for all your help but i think im gonna shoot myself in the foot. its probably a lot less painfull
Code:cin.get();cin.get();
http://www.functionx.com/
Best tutorial ever.
BTW, what compiler are u using?
Adding cin.get() to the end of main doesn't fix anything except for the fact that some development environments (e.g. MS VC++) keep the console window open after the program has terminated when run from the IDE and some (e.g. Dev-C++) don't. By adding cin.get() you pause the program until the user presses enter.Originally posted by vex
ok i got the program working by copy and pasting sircrono6 code. but sircrono6 you asked me " am i coping the code properly" i assure you i have and the only reason your code worked is that you added 2 more lines to the bottom of the code. why does this fix the problem and why isnt it in tutorial then? how am i suppose to learn when its not even a full code. thanks for all your help but i think im gonna shoot myself in the foot. its probably a lot less painfull
Code:cin.get();cin.get();
Adding cin.get() twice in a row is what people do when they don't realise why it doesn't work sometimes if you only add it once
Gambling. The new yoga, with cash prizes!
im using devc++ 4.9.8.0. thanks for the link to function X death wraith. im about to try it out now. hope its better than stupid one on this website.
p.s love the function x moto learn by practicing and practice by doing. ill get back to you on how i go. thanks for the help.
heck, nothing will replace a good C++ bookOriginally posted by vex
thanks for the link to function X death wraith. im about to try it out now. hope its better than stupid one on this website.
source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense
i know but im a cheap bastard. i have changed to c instead c++ and i aint having any problems. go figure aye. maybe if this goes alright ill buy a book
thanks all
p.s for all you tech heads out th there please keep your answers simple for the new kids. half the posts i didnt understand cause i wasnt that advanced yet. keep up the great forum guys.
bye for now
Sorry about that Vex, but good luck with C, I hope you do well in it If ya ever come back to here, I hope ya understand it better, been a good time, so cya later.Originally posted by vex
i know but im a cheap bastard. i have changed to c instead c++ and i aint having any problems. go figure aye. maybe if this goes alright ill buy a book
thanks all
p.s for all you tech heads out th there please keep your answers simple for the new kids. half the posts i didnt understand cause i wasnt that advanced yet. keep up the great forum guys.
bye for now
OS: Windows XP Pro CE
IDE: VS .NET 2002
Preferred Language: C++.