Using structs, i suppose. Then writing your own specialized bubble sort for the particular structure used.
Type: Posts; User: Tool
Using structs, i suppose. Then writing your own specialized bubble sort for the particular structure used.
Thanks you, rags_to_riches. :)
Oh my god.
This is probably the only example in the book without the return statement, and i agree with authors taking it out - it's done because they didn't want to confuse beginners with...
Ofcourse - what i'm saying is that pieces will be missing, MANY pieces, but you will have absolutely no problem in learning and easily comprehending those pieces.
You might be reffering to K&R first edition - there might be such deprecated examples there, but i've never seen such a thing in K&R 2nd edition.
Possibly, i've seen main() without int in front of...
I'm 100% sure i've never seen a K&R example with no return statement in main function.
Never had problems running any code from K&R in 2010, therefore i'm preety sure it conforms to the standard.
The reason i am suggesting K&R is because i have read the whole book, did all the...
No, no and no!
K&R is the best C book out there - made by creators of the C language.
Is there a way to find this out?
I looked up on google, but the only related thing i found is _setmaxstdio which is a C function. I suppose it also applies in C++?
Also, what does this depend...
So, a good thing to do would be to include type definitions into a .h file and then just include the .h file in the files which depend on those types?
I was wandering why this works:
file1.cpp
#include <iostream>
struct Point {
int a, b;
};
if(gross_income>=2000)
if(gross_income<=4000)//second salery step
Something like this?
Is there a way to pass a 2d array to a function without the function knowing how many elements each row has?
If not, i'm interested about what does "inverting" a 2d array means?
Replacing first...
"How would you choose names for pointer to function types defined using typedef"?
This is one of the questions in The C++ Programming Language book by Bjarne.
So what do you think are...
What does that exactly means?
The problem states:
Write a function to invert a two dimensional array.
Does this means reversing each row of the matrix?
So, while learning C++ from the stroustrup's book i often wandered this.
At some point of the book, "inline" keyword is introduced in the book, it is described a little with no examples.
So,...
True, i figured that just out. Thanks. I'll look it up...
Hm, the code seems to crash in merge_stats function (i marked it red) and i have no idea why? When i enter only one name and value, it's ok, but when i enter more then one name and value it...
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
//undefined behaviour?
int i = 100;
*(char *)&i = 25;
cout << i << endl;
Well... the original code was this:
#include <iostream>
#include <iterator>
#include <list>
#include <algorithm>
#include <set>
#include <iostream>
#include <list>
#include <algorithm>
#include <set>
#include <iterator>
using namespace std;
int main()
{
Is it more correct to do it with constructors, or just passing a const char pointer?
#include <iostream>
using namespace std;
int main()
{
I'm a bit confused about what the expression belove in the code returns.
cin >> buf;
And how can it be used in a while loop:
string buf;
while(cin >> buf) //extracts until eof
template <class C, class T> int count2(const C &v, T val)
{
C::const_iterator i = find(v.begin(), v.end(), val);
int n = 0;
while(i != v.end()) {
++n;
++i;
...
#include <iostream>
#include <vector>
using namespace std;
struct Entry {
string name;
int number;
};