I found a great c++ snippet archive
http://davidw.awardspace.com/index.p...rograming.html
why dont i see more great web pages like this one??
please post any links for pages containing whitty little functions like the one above
I found a great c++ snippet archive
http://davidw.awardspace.com/index.p...rograming.html
why dont i see more great web pages like this one??
please post any links for pages containing whitty little functions like the one above
Where I stopped skimming:Originally Posted by squako
Perhaps because the originator needs to learn a little more first?Code:while (! myread.eof() )
[Visit the FAQ to see why. If you go against an FAQ, count yourself in the beginners-intermediate group.]
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Beh, the site saw me coming, and refused to let me in to have a look....
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Nice broken link...
- The user input snippet is awesome!
- I also like the delay snippet. It's important to put your processor at 100% when delaying an action.
- The Combine Two Strings function is essential! It's easier to call a function with the prototype string addstrings(string a,string b) than to write a + b!
I also like using namespace std; all over the place, overflowing ints here and there, the caring concern for proper indentation, the use of C-style casts and this particular snippet of code to convert a string to a float got itself a place in my heart.
The masterful indentation, the little detail of breaking the function header in two lines and the absolute geniality behind this useless... useful piece of code.Code:template <class T> bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) { std::istringstream iss(s); return !(iss >> f >> t).fail(); }
EDIT: Are you the author of this, one-time poster? *bows*
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
its not good c++??
it worked for me.
do you know of a page that has a bunch of c++ operations like this that are better? Please share Because i haven't been able to find it. Thats really why i posted this thread.
Those two properties traditionally have no relation in C++.Originally Posted by squako
http://www.boost.org/
Familiarize yourself with what is offered by this site. It offers an astounding amount of stuff, written by some of the best C++ programmers out there.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
yea, i suck at programing in c++, but i can program in it just because of a bunch of code snippets. I figured that would be usefull to someone else. But if its terrible c++, i dont want to loose respect of all the c code masters.EDIT: Are you the author of this, one-time poster? *bows*
I took the page down.
can you guys tell me they easy way to set up a c++ option parser?
c++ option parser = ?
If you are finding it hard to learn the language, then get a good beginners book. Looking at code written by proffesionals is likely to get you even more lost and confused. These are people with years of experience. Saying that, everybody has to start at the beginning of somthing new. No one person can ever learn the language inside out and back to front. Its just not possible, its too big. ( C is different, in comparason it is quite a small but complex language ) You just need to learn all the basics, learn them well then put all this into practise with coding your own programs. You then have to pick at the language and take out the bits and preices you "need" to learn for whatever reason you want to program. ( Ie: games ).yea, i suck at programing in c++, but i can program in it just because of a bunch of code snippets.
Double Helix STL
c++ option parser for command line programs
You mean like this - http://clusty.com/search?query=getop...Mozilla-search
There are many ways (and libraries) to do this for you.
Or you can be inspired and make your own.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.