mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Of course, for such a project, you will have to do significant changes to the OS anyways, and in that sense, will end up developing a new derivative or variant of an existing OS.

One good option seems to be MeeGo or one of its derivatives. There are a number of different user interfaces / derivatives, I'm sure one of them will fit the bill.

Another option is to take a desktop distro which has a tablet- or phone-friendly interface, like KDE-netbook / Plasma Active, or Ubuntu Phone. Then, you can strip down the OS by removing components / features you don't need or cannot support on your limited platform.

I would recommend a Qt-based GUI (such as KDE, or Qtopia), because they are really nice (nice looking and easy to program).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Maybe Republicans had a good reason to attempt to suppress the black vote -- the Republicans just had a rotton candidate. Maybe the Republicans should have also tried to suppress the white vote because Obama got a lot of those too. :)

With the more recent inclinations of the Republican party, I wouldn't be surprised if they tried to suppress the vote, period.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Thanks, but there should be a simple solution, because teacher can't ask what he hasn't taught yet.

Well, programming is all about being able to learn on your own, because no amount of course-work is going to be enough to be proficient. So, who says the teacher can't ask for what he hasn't taught yet? If I were a teacher, I know I would do exactly that.

The other possibility is that your teacher has very very low expectation on the quality of the code that his students are supposed to produce. For example, he could expect you to produce the following:

#include <iostream>
#include <vector>

struct student
{
  int* subjects_number;
};

int main()  // <--- NOTE: main() must return an integer.
{
  int NoOfSubjects = 0;
  cin >> NoOfSubjects;

  // create a student record:
  student my_student;

  // allocate the array of subject numbers:
  my_student.subjects_number = int[NoOfSubjects];

  //... now you can access each subject number as 'my_student.subjects_number[i]'

  delete[] my_student.subjects_number;

  return 0;
}

But the above code, although correct for this trivial example, is absolutely horrible, and teaching to do this can be very damaging to the students' future coding habits. In the real world, the above code is complete garbage, it's a "throw it away and fire the guy who wrote it" situation, because anyone who thinks it's OK to code like this shouldn't be working for you.

MRehanQadri commented: Thanks Mike. +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

The more formal name for the "heap" is actually "freestore memory". In short, all the memory consumed by local variables is on what is called the "stack", which grows (by stacking more and more variables) as you declare more local variables and as you call functions that have local variables in them. Each function, with all its local variables (including function parameters), consume a certain amount of memory, but that memory is fixed at compile-time (i.e., the compiler generates static code that allocates those variables on the stack). If you need a certain amount of memory but it is unknown, at compile-time, how much memory you will need (e.g., like in the example, you don't know how many characters you will need until you have the argv[1] string, which is obtained when running the program), then, you need to allocate that memory dynamically (at run-time). The heap or freestore memory is there for that purpose. And yes, you allocate such memory by using the new operator, and you deallocate that memory with the delete operator (once you no longer need it).

The most basic example is this:

#include <iostream>

int main() {
  int run_time_count = 0;
  std::cout << "Please enter the size of the array: ";
  std::cin >> run_time_count;

  // allocate an array of the specified length from the heap:
  int* p_array = new int[ run_time_count ];

  // at this point, p_array is a pointer to the first element of 
  // the newly allocated array.

  // fill the array …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What ever gave you that impression?

Uhmm, maybe the 37 states that tried to pass voter ID laws. A democratic state has two options, either make sure your people are not too poor to prevent them from having a valid ID, or don't require one to vote. Most developed countries went with the former, the US is stuck with the latter, for the moment. You cannot require voter ID if you can't ensure that everyone can easily and affordably get a valid piece of ID, which is currently not the case in the US.

Democrats (most minorities are democrats) are often known for duplicate voting, and voting for dead people.

I think someones been watching too much of Fox News. Voter fraud, in that sense, is "virtually non-existent".

USA does not have "districts". We have "counties".

Well, in Louisiana, they're called parishes. Whatever the name is, who cares.

It is unlikely we will get rid of the electorial college system, it has been tried several times in the past with no results.

It's incredible how resistent to change people are in the US (or how loud the hard-line conservatives are). The electorial college system was set up to ensure a reliable, in person, communication of the districts / counties results, in a world where that information had to be relayed by travelling on horse-back from the state in question to Washington. It's an archaic system that hasn't made the least …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

First of all, your loop is infinite:

while ( numberLength / 3 != numberOfGroups || numberLength < 3 )
{
    strcat("0", argv[1]);
}

Because the values in the expression ( numberLength / 3 != numberOfGroups || numberLength < 3 ) are all constant throughout the loop iteration, so if it starts (evaluates to true), it will never end (the condition will always evaluate to true). A simpler way to check if the length is not an even factor of three is (strlen(argv[1]) % 3) (if non-zero, it means it is not an even factor of three).

Second, for the problematic expression, strcat("0", argv[1]);, if you read the reference page for strcat(), you will see that the first parameter (i.e., "0") is supposed to be the destination, not the second argument (as you seem to think). And, the destination must be large enough to hold the entire destination string, which is clearly not the case here because the string "0" is only big enough to hold one character and the null-terminating character.

I think that the method you are using is beyond repair, you must change your strategy. First, you will need to allocate an array of characters big enough to hold argv[1] + leading zeros + the null-terminating character. The number of characters in the final string can be calculated as the first 3-even number above or equal to the length of argv[1]. This can be computed as:

int old_str_length = strlen(argv[1]);
int new_str_length = …
tux4life commented: Nice that you took the time to explain it step-by-step :) +13
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

In contrast they don't have as strong an economy relative to the rest of Canada and I believe they have more debt per capita than the rest of Canada. There is also a lot of problems with corruption in Quebec.

Yeah.. we're trailing the pack on that end. Part of it is due to the government letting itself get screwed by corporations exploiting the natural resources, and another part of it is the government screwing people over for the benefit of their friends in the Mafia (left over from the good ol' days of the Montreal-NY drug trade (i.e., during the "French connection")). And another part is the federal government subverting many sectors of the economy from being able to flourish in QC, mostly to the benefit of Ontario (mostly under the Liberal Party's reign).

Quebec's national debt is around 170 Billion dollars (not as high as Ontario, but still high). However, one of the major assets we have is Hydro-quebec (until recently, the single biggest electric power company in North America), which alone is estimated to be worth in the neighborhood of 250 Billion dollars. When you evaluate the financial state of any company, you always look on both columns: assets and debts, and you check to see the difference, but for some reason (I have my suspicions about that), when it comes to governments it seems that only the "debt" column is looked at. This is accounting 101: the assets balance the debts and the difference …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I can see methods in stdio.h, iostream, etc in Turbo C++.

Please define the term "see". Do you mean that you are opening those header files and looking at their implementation? Do you mean that Turbo C++ has some help menus that list the standard functions? Do you mean that Turbo C++ can guess at the functions (from the standard) you want to use before you finish typing them (code completion)? I don't know what "see" means in this context.

If you need a set of reference documentation on all the standard functions, refer to: http://www.cplusplus.com/reference

If you need code completion, then CodeBlocks has reasonably good implementation of that. Make sure that it is turned on.

If you need to look at the implementation of those header files, well, they normally appear in the MinGW folder (either a sub-folder of CodeBlock's installation folder or as a separate installation (possibly directly in C:)), within that folder there should be one named "include" and it contains all the standard header files.

If it is something else you need, please define what you mean by "see".

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Here are a few facts that you need to know:

  1. Floating-point numbers are fixed by IEEE standards and do not differ between platform (except for extremely archaic ones). This means you don't need endianness conversions for float or double.
  2. Endianness conversions (e.g., htonl / ntohl) work on fixed-size unsigned integer types. The network conversion functions ending in l (for "long") use the integer type uint32_t, which is a fixed-size (32bit = 4bytes) unsigned integer type.
  3. The network byte-order conversion functions come in pairs. That is, htonl means "Host TO Network byte order for Long integers", and ntohl means "Network TO Host byte order for Long integers". You use htonl to prepare the value to be sent over, and you use ntohl to re-order the data that you have received from the network (to put it in proper order for the host platform).

So, you positional data should be of the following type:

  uint32_t time;
  float LAT;      // or: double LAT;
  double LONG;
  uint32_t ALT;

And before you send to the network, you need the following conversions:

// reverse the byte order of everything
  uint32_t time = htonl( uint32_t(currentTime) );
  uint32_t ALT  = htonl( uint32_t(AC_Alt) );
  // NOTE: the floating point values don't need conversion.

And, as a tip, a slightly nicer method for constructing the message is the following:

// Copy it all to message
  std::string message;
  message.append( (const char*) &time, sizeof(uint32_t));
  message.append( (const char*) &LAT,  sizeof(float));
  message.append( (const char*) &LONG, sizeof(double));
  message.append( …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

To do this properly, you need to do a lot of work, and it will become a full-blown class (with private members, non-trivial constructor / destructor / copy-constructor / copy-assignment operator, etc.). Here is a good tutorial about this.

Objective: students could have taken different number of subjects. Now modify the structure such that its variable subjects_numbers has type pointer to int so that we can store scores for different number of subjects for each student.

Is this a self-imposed problem statement from you? Or is it what was given to you as an assignment? Because if this is what is required of you (have a pointer to int as member and do the allocation of a dynamic array with new/delete), then you have to follow the tutorial I linked to and adapt it to your problem context. But if you are not required to do that, then you should use the standard class std::vector:

#include <iostream>
#include <vector>

struct student
{
  std::vector<int> subjects_number;
};

int main()  // <--- NOTE: main() must return an integer.
{
  int NoOfSubjects = 0;
  cin >> NoOfSubjects;

  // create a student record:
  student my_student;

  // resize the vector of subject numbers:
  my_student.subjects_number.resize(NoOfSubjects);

  //... now you can access each subject number as 'my_student.subjects_number[i]'
  //     just like a normal array.

  return 0;
}
MRehanQadri commented: Thanks, but there should be a simple solution, because teacher can't ask what he hasn't taught yet. +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You are already using the function that you are looking for. The function system() executes a command. In this case, you are executing the "pause" command. You can use the same function to execute other commands, including your own program. It's as simple as that:

system("InputProgram.exe myargument");

There are also more native Windows functions to do the same (with a bit more control), such as CreateProcess().

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Post your code. It's hard to speculate on what you are doing wrong without it.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

This error message means that you are accessing an address of memory that is not reserved for your program. This usually occurs when you read or write at a location pointed to by an invalid pointer or beyond the valid memory that the pointer points to. For example, these are three potential segmentation fault cases:

int main() {

  int* p1;   // an uninitialized pointer is invalid.
  *p1 = 42;  // ERROR! Segmentation fault!

  int* p2 = NULL;  // the NULL location is a universally invalid value for a pointer.
  *p2 = 42;  // ERROR! Segmentation fault!

  int* p3 = new int[4];  // allocating an array of 4 integers. 
  p3[4] = 42;  // ERROR! Segmentation fault! (index 4 is beyond the valid memory)

  delete[] p3;

  return 0;
};

There are, of course, countless more situations, but they usually boil down to one of these cases.

I'M tryin to use strcat() to add "0" to the left end of char *argv[1]

You cannot do that. If you read the reference on strcat, you will see the following description of the "destination" parameter (first parameter to strcat):

"Pointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string."

If the destination memory location is not large enough for the total string, then you will get a segmentation fault (i.e., writing beyond the chunk of valid memory that "destination" points to).

I don't know exactly how your code …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

32-bit binaries cannot be mixed with 64-bit binaries, period. There is no (easy) way to create an application that would link to some 32-bit libraries and some 64-bit libraries at the same time. Basically, if the program is 32-bit, then all its libraries (include shared-objects (.so files)) must also be 32-bit, and the same for 64-bit. The two cannot mix. In other words, x86-64 platforms can run either processes that are either 32bit or 64bit, but not a process that has a mix of both.

The solution is to compile OpenCV in 32bit too. (or get a 32bit version (i686) from a ppa repository).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Panasonic

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Airbus

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

GEICO

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I think Danny Trejo is an awful actor with awful films... (my opinion so don't get mad...)

Maybe not the greatest actor, but he's an awesome guy.

LastMitch commented: Nice! +0
diafol commented: great link +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Toshiba

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

So far what I've heard is that Quebec basically wants to be friends with benefits.

That was René Lévesque's concept of sovereignty-association. The idea is that Québec would be a sovereign state with: its own constitution, its own laws, its own international representation, and its own (exclusive) tax collection. However, the association part would involve things similar to European Union states, like sharing the currency, sharing customs (i.e., like in the EU, if you are allowed to be / work in one EU state, you can go to another EU state too without crossing customs, it would be the same between Canada/Quebec), and possibly things like the postal service. Of course, any thing that the canadian government would do for Quebec (e.g., let's say we kept Canada Post) then Quebec would pay its share towards it. This is, in part, aiming to make the transition easier, i.e., transition from a "federation" to an "association", and then maybe re-negociating / re-structuring the association, which is not possible in a federation (without demanding "special" constitutional status, which raises way too much ire in the rest of Canada to ever happen).

The point of this, as diafol said, is self-determination, or as we call it "Maître chez nous!" (translation: Master in our own home).

To a large extent, however, there wouldn't be that much talk about separation if the canadian federal government actually stuck to the things it was supposed to do. The constitution basically says the federal government must do …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Kodak

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Have you defined a copy-constructor? One that performs a deep-copy? You need to obey the rule of three when you write a class that holds a resource. You can also read this tutorial.

The double-destruction comes from the fact the your object must be getting copied, and when copied, it only copies the pointer, not the data it points to, and thus, you have two objects holding the same pointer, and when the second object is destroyed in calls delete a second time on the same pointer.

If you want to save yourself the trouble, just use the standard std::string class instead of a C-style string (char pointer).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Here's something, I hope it's not too complicated:

#include <iostream>

int main() {

  // create an array of C-style strings (const char*):
  const char* messages[] = {"Hello World!", "The answer is 42.", "Because the bold man told you so."};

  int selection_index = 0;
  std::cout << "Select the message you want displayed (0-2): ";
  std::cin >> selection_index;

  // declare a pointer to a C-style string, (or a pointer to pointer to const-char)
  // set the selection pointer to point to the string that was selected:
  const char** selection = &messages[selection_index];  
  // or, equivalently:
  // selection = messages + selection_index;

  std::cout << (*selection) << std::endl;

  return 0;
};

If the expression &messages[selection_index] confuses you, here's the explanation. Doing messages[selection_index] gives you the selection_index element from the messages array of const-char pointers, so, the resulting type of that expression is const char*. Then, the ampersand & takes the address of that element, and thus, returns a pointer to that pointer, i.e., it has the type const char**.

The alternative expression, which is messages + selection_index, is a bit simpler. In this case, the messages array decays to a pointer to the first element of the array, and so, it has the type const char**. Then, adding an integer to a pointer has the effect of moving the pointer by that integer amount, resulting in this case to a pointer to an element selection_index positions beyond the first element of the messages array. In other words, the result is the same as …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Atari

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

what is xquery, unless you meant jquery?

No, I meant XPath/XQuery. It was part of a Database / Data-mining course I took some years ago. It's an XML-based scripting language to parse, search and transform XML data and schemas, and it can be used to interact with databases too. I don't know if it's really useful (certainly not much to me), or if it was just used as a learning tool in that course. But it's a neat little language, for what it's designed to do.

From my University days, FORTRAN, APL, PL/1, ALGOL, ALGOL 68C, SNOBOL, COBOL, Lisp, 360 Assembler.

Wow.. your university days must have been really painful..

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

From my teenage years (cerka 5 years): VisualBasic and Delphi.

From work experience / thesis-work (cerka 8-10 years): C, C++, Matlab/Simulink, Fortran, LabVIEW, Assembly (reading only), KRC-RSI (Kuka Robot Controller - Remote Sensor Interface language), Bash, and Python.

From course-works (which is rather insignificant): Java, MySQL, HTML, and XQuery.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I have been told that in C++ the concept of a string does not exist. A string is just an array of type char.

Yes and no. At the fundamental level, a string is just a sequence of characters, and in that sense, an array of characters. This is the case in all programming languages, some expose that directly, others hide it in a standard library feature, and others hide it in a language feature.

In C, creating and manipulating strings is done through the creation and manipulation of an array of char, terminated by a null-character (i.e., usually called a "null-terminated C-style string"). C++, like any other C-inspired language, inherited that from C, however, the C++ standard library has a class called std::string (from header <string>) that hides away all these annoying details of the creation and manipulation of an array of char, and exposes much more convenient and rich functionality than raw arrays of char. So, the answer to your question is that the "concept" of a string is not embedded in the C++ language, but there is a standard string class that takes care of that. In practical terms, whether the language has strings as a language feature (e.g., Delphi or Java) or as a standard library feature on top of a more "low-level" representation as an array of char (e.g., C#, C++/CLI, Python, etc.), the difference is negligible. And in that sense, "does the concept of a string exist in C++?", yes, as much …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well, I have a great deal of distaste for switch statements overall, in part because I find the syntax ugly, and in part because they are often an indicator that there's something you are missing out on an opportunity to have a more flexible design. In other words, when you leverage polymorphism well (statically or dynamically), you don't really need to use switch statements all that much. But with that said, there are definitely many uses for switch statements (some are necessary, others are just more quick and convenient than a more "designed" alternative). And my personal taste in the matter does not amount to a coding guideline, for sure, so, use them if you want to.

As for nested switch statements, I don't see any problems with that, as long as it is properly spaced out and indented. And obviously, you don't want redundancy (repeating a very similar nested switch statement again and again), if that's the case, consider rethinking it to see if it is possible to avoid that (e.g., putting the nested code into a separate function, or using dynamic polymorphism).

But take note that humans can keep on average 7 different things in their head at one time. The more variables you use, the harder it is to mentally keep track of them all when reading the code.

Yes, that's a good point and common-sense should always apply whenever following any kind of coding guidelines (whether stylistic or about code correctness). In my experience, …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

That's a nice question. Code readability is really important.

Here are a few tips:

1) Leave the explanation of what a function does outside the function, and the comments about how it is done inside the function, near the code that does it.

2) Use meaningful and complete names for the variables and classes.

In your code, I see a lot of names like "Object", "Polygon", "Physics", "Motion", "Ntime", "Yvel", etc... which are either too general to be meaningful or too short to the readable. As the saying goes, typing is cheap, reading is expensive. In other words, the time you spare by typing shorter names or by not taking the time to come up with more meaningful names is time you're gonna lose many folds when you come back around trying to discypher what the code means.

3) Use verbs in function names.

A function is supposed to do something, and its name should reflect that. Your function is called "Collision". What is that supposed to mean? Is is checking for a collision? Is it (also) reacting to a collision (e.g., bounce the objects)? Is it computing a collision force? I don't know because I don't know your code (until reading the implementation), and your function's name is not helping me.

4) Let the code talk for itself.

If you follow tip 2 and 3, you'll find that code will read like prose (sentences). For example, here's a line of code from some of my own code (from some …

bguild commented: Educational and extensive! +5
tux4life commented: People should read the C/C++ forums on a more regular basis, even if it were only to read your posts. Keep up the nice posting ;) +13
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

British generally refers to either the UK or Great Britain, where the former refers to the main island (with England, Scottland and Wales) and Northern Ireland, and the latter refers to just the main island. England is just one part of the main island, and the other states (Scottland and Wales) are semi-independent. So, being Scottish means you're British, and being English means you're British, i.e., it's a super-set / sub-set thing.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Varg Veum films series have 12 films? Is this within a 10 year period? It's like a 1 film a year.

According to IMDB, it's 12 movies in 5-6 years (2007 to 2012).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

One, I need a simple way of rendering a GUI with minimal headache.

I highly recommend Qt. It is in C++ (so, familiar territory for you, and no need to have an elaborate front-end / back-end design), and it is cross-platform (works anywhere, include mobiles). It is pretty much as easy as it can get for GUI programming (drag-drop designer, simple build method, feature-rich components, etc.). When I first learned to use it, within about an hour I was finished with what I had to do, it was a very simple GUI, but still, I never expected it to be that easy to pick up.

As you mentioned Ogre, I'll also mention that Qt integrates very well with OpenGL, and with Coin3D (aka Open Inventor) through SoQt. You can get a 3D scene up and running in no time, integrated inside a Qt GUI.

Two, I need a way to save data as classes and objects and a way to search through this

That's called Serialization. There are tons of options in this regard, both in terms of useful file formats that can form the basis for all your files, and in terms of libraries that do it. Most serialization libraries will support many of the different formats that are typically capable of storing a complex object architecture of various classes.

For file formats, the most popular ones are XML (or XML-like files), Google's Protobuf (used by Google for everything), and JSON …

Aarowaim commented: Thanks for the wonderful suggestions. I was definitely looking for something other than visual basic +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Welcome to Daniweb!

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Lining up Varg Veum: Din Til Da Den

Uhh.. I had a moment of guessing at what this title was supposed to mean.. until I realized you mispelled it: Varg Veum: Din Til Døden.

I haven't seen any of the Varg Veum films, but have been recommended them a few times, it appears I have a lot of catching up to do (12 movies!).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

..... bla bla bla ... I get so tired of hearing this kind of BS. The older generation whining about how the younger generation is on the road to perdition. This is as old as the world itself, things change all the time, and the older you get the easier it is to get the impression that the world has moved beyond your grasp, and you start to long for the good ol' days. One of the oldest newspaper article recovered from England, from 1600s, just happened to feature an editorial article that pretty much said the exact same thing as you (Everyauction) said here, and prophecizing that total mayhem would reign in a couple of generations if things kept going in this direction (but it appears we survived... uh.. and things got dramatically better too... oh well, I'm sure this time the prophecies will come true, and mayhem will reign in a few generations).

It can be hard to adapt to a changing world, and it can be easy tip over to the side of frustration and cynicism as you get older. But you should be aware that this is nothing more than a well-known and well-studied sociological phenomenon as people get older (passed the average age of the "active population"). Some people are less affected than others, it depends on the individual, but it's a natural thing, and you have fallen prey to it.

When I hear this kind of talk, all I think is: "poor old man …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well, you can proceed by elimination. I'm gonna try to explain without giving it all away.

Hint 1:
In an undirected graph, every edge that is counted on the degree of one node must also be counted in the degree of the other node to which it leads. For example, this list of degrees is possible:

0 1 0 0 1

because, clearly, there is an edge going from node 2 to node 5, i.e., it is counted twice, once in node 2 and once in node 5. On the contrary, this list of degrees is impossible:

0 1 0 1 1

Hint 2:
If the graph cannot have redundant edges (i.e., multiple edges going from the same source to the same destination), and that the edges cannot be looping back directly (i.e., source node and destination node are the same), then any one node cannot have a degree higher than the number of other nodes with a non-zero degree.

I tried not to spell out the answer too obviously... no sure if I succeeded.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What you are talking about is nowhere to be seen in the bug report you linked. The word "cache" does not even appear anywhere in the page not even once

From the first sentence: "if you tried to eject a flash drive and all data were still not synced to it". If that isn't clear enough for you, I don't know what will. If you thread in the realm of developers, you have to understand the vocabulary.

Same thing. Nowhere is this mentionned.
There is no such umount flag mentionned when you type umount -h on a command line.

Here's what 1 minute of googling can do for you:

--mount-options sync

I can't keep spoon-feeding you this stuff.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

This looks like a classic case of heap fragmentation. This is a rather classic problem which will cause the memory consumption to grow larger and larger even when the memory that you actually use is not increasing (no leaks). Normally, this will stabilize to a fixed amount of memory consumption after a little while.

To reduce fragmentation, you should, of course, avoid doing lots of dynamic allocations of small chunks of memory. For example, allocating lots of single objects with new is a typical driver of such fragmentation problems. Of course, in C++, you shouldn't be allocating lots of single object with new because there is no need for it, use stack-based local objects instead, and dynamic memory only for arrays (through STL containers).

Ketsuekiame commented: VLD is pretty good, so there's no real need to second guess it. Mike's proposition looks correct and is an example of good practice +8
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

b) the delayed write problem has nothing to do with nautilus which is not involved at all in this. I can think right away of many reason this bug could occur, some relating to serialised background thread launched by the kernel that are not reported back to the command window nor known by the typical user (like you), possible usb driver misprogramming (quite possible) or another possibility is that this particular usb has its own embedded circuit that moves the data inside itself from a rapid memory to a slower memory and that it flashes during that time (even though the data has completed its writing to its fast memory and therefore should be safe even if the usb removed) though that hopeful and reassuring scenario of delated writing inside the usb is somewhat far-fetched but still a possibility.

Read the bug report I linked to in my previous post. The issue has been identified and fixed, you don't need to speculate about what the source is. The issue is that newer flash drives and hard-drives have a hardware cache unit to speed up the reading / writing by buffering the data. The umount command can handle this already via a flag (command-line option to the command) that tells it to first request a sync'ing of the hardware cache (i.e., flushing the cache). Linux distributions like Fedora and Ubuntu use a desktop environment called "Gnome" which wraps those kinds of file operations and gives them additional functionality (e.g., …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

After digging a bit, this appears to be a bug reported of Gnome 3.2 / Nautilus, and has been fixed in the up-stream. The bug was reported on Dec. 7th, 2012, and was fixed in Dec. 20th, 2012. See the history of the bug here from Fedora's bug reports (uses the same desktop environment (gnome-shell) as Ubuntu). You might want to reflect the bug report on Ubuntu's bug reports, in case they haven't been made aware of it. The fix is (or will be) up-stream, so if you want it, you will have to sync to an up-stream repository. It appears that the main reason is the newer cached operations on flash drives and external HDDs that wasn't handled correctly in the gnome-shell / Nautilus code.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You should learn about passing by reference. As in:

static DATAEDITING_API bool Contains(const std::string& target, const std::string& source);

static DATAEDITING_API bool Contains(const std::string& target, const std::vector<std::string>& source);

static DATAEDITING_API bool Contains(const std::string& target, const std::string& source, bool sensitive);

static DATAEDITING_API bool Contains(const std::string& target, const std::vector<std::string>& source, bool sensitive);

And:

bool Editor::StringHandler::Contains(const std::string& target, const std::vector<std::string>& source, bool sensitive)
{
    for (auto i : source)
    {
        if(Contains(target, i, sensitive)) { return true; }
    }
    return false;
}

As for the problem, I can't tell what it is, there isn't enough code. The loop seems right, so the problem must be in the string-string "Contains()" function that is being called in it.

P.S.: What is DATAEDITING_API? It is a bit bizarre that you have both a static keyword, and what looks to me like a MACRO for something like extern "C" __declspec(dllexport). If the functions are static member functions, then OK, sort of. But if they are free functions, then it shouldn't work. Also, you should be aware that it is a bit tricky to export C++ constructs from a DLL, including both overloaded functions and standard library components like std::string or std::vector in the parameter lists of your functions. The name-mangling and the binary layout of these things are not portable between compilers, compiler options, and platforms, which more or less means that you'll have to recompile the DLL for every application that uses it, which kind of defeats the purpose of it all. …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well, I dug around a bit and it appears there is a bug report about this problem with Nautilus here. Feel free to vent your misfortunes there, and petition to have it assigned a higher priority.

I am quite a bit puzzle by your slugishness in that you haven't already tested yourself on your 'Dolphin' which is probably a copy (with a different name) of the 'Nautilus' I am using.

Why would I do that? I have no stake in this. And Dolphin is not a copy of Nautilus. I use a KDE-based distribution, things like progress bars for file transfers / copies are handled differently, and it has been flawless in my experience with it. But, of course, for any kind of heavy-duty file manipulations / transfers, I do it in the terminal anyways, because it's faster.

But let's test it yourself as I did and see the result:

1) Use cp to copy a large file (say a 8gb file) to a usb drive.
2) See how cp returns before the file is actually finished copying (see the flashing light blink on your usb). Neat, would you normally think: the system can do the task in the background! But wait...
3) Now while the file is still copying in the background and your usb file is flashing: umount your drive!
4) Surprise, surprise: umount returns successfuly BEFORE the file copying has been completed.
5) And remember not every usb …

bguild commented: Thoughtful and detailed +4
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

BTW - do ya think you could type in a Frngench axe-ont frngom know ôn, mon cher?

Well, Ay-eh can-eh try-eh too typ-eh wid eh québécouay haxent..

Reverend Jim commented: très amusant (eh) +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

One of the better options would be to do this:

class Shoe
{
public:
    //Constructors
    Shoe();
    Shoe(string Name_, double ShoeSize_, int Number_);

    //Destructor
    ~Shoe();

    //Getters
    string getName() const;
    double getShoeSize() const;
    int getNumber() const;

    //Setters
    void setName(const string& Name_);
    void setShoeSize(const double ShoeSize_);
    void setNumber(const int Number_);

    //Variables
    string Name;
    double ShoeSize;
    int Number;

    static bool compareByName(const Shoe& lhs, const Shoe& rhs) {
      return lhs.Name < rhs.Name;
    };

    static bool compareBySize(const Shoe& lhs, const Shoe& rhs) {
      return lhs.ShoeSize < rhs.ShoeSize;
    };
};

And then, your Shoe_List::sort() should use std::sort() instead of qsort (which is an old C sorting function, not recommended in C++):

void Shoe_List::sort()
{
    char input;
    cout << endl;
    cout << "Sorting options" << endl;
    cout << "1. Sort by Name" << endl;
    cout << "2. Sort by ShoeSize" << endl;
    cout << "3. No sorting" << endl << endl;
    cout << "Enter option: ";
    cin >> input;
    cout << endl;
    switch(input) 
    {
        case '1':
            std::sort(shoes, shoes + length, Shoe::compareByName);
            break;
        case '2':
            std::sort(shoes, shoes + length, Shoe::compareBySize);
            break;
        case '3':
            return;
        default:
            cout << "Invalid entry" << endl << endl;
            break;
    }
}

And, as deceptikon pointed out, the even better practice is not to use a C-style array (Shoe* shoes;) but rather a C++ standard container such as std::vector<Shoe> shoes; in this case.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I see you vented a bit there.

I will admit that GCC's build configuration is not the greatest, mostly because they use an antiquated system called "autoconf". This is a configuration tool they wrote decades ago (long before Linux), and it simply hasn't been able to keep up with all the additional complexity of modern-day operating systems (remember, in the days of its inception, the entire operating system could fit on a floppy disk (1.2 Mb)). Switching to a newer and better configuration system (e.g., cmake) would be an enormous task, and a very boring and painful one, something that open-source developers aren't rushing in to volunteer for.

As for the file copying, you must know that all the "real stuff" in GNU/Linux is done under-the-hood by small command-line utility programs (e.g., cp in this case). These programs are extremely reliable and well-behaved, you can be sure of that, and it is largely the reason why Linux/Unix/Solaris servers can run for years without any major hick-up, while Windows servers can at best run continuously for about 1 month before something "weird" happens, requiring them to go down and reboot. If you experience something quirky in Linux, like what you described, it is usually due to the GUI program, because these are typically written by novice programmers and enthusiasts that are just doing this to learn or make their mark. The GUI programs and desktop environment is one of the weakest points of Linux, since it simply hasn't been the focus …

bguild commented: Thoughtful and detailed +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Agreed, those american beers are just sparkly water with a bit of yellow colorant.

I'm not a big fan of Heineken either.

Here (QC), we have some local beers that are pretty good, mostly Beligium-style beers.

I'm also a big fan of German and Danish beers.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

If I install gcc 4.8, and then later I install other software (automatically with ubuntu software manager or manually), will this wreck everything (at least in some cases) as (possibly) the software downloaded is written for an earlier version of gcc (4.6) and might be incompatible with gcc 4.8 and crash on compilation or later?
If so, should I instead install everything I think I will need before installing gcc4.8? Would that work or will I be facing other problems?
Or is there nothing to worry about here?

This mostly depends on where you install gcc 4.8. It is surely a good idea to install the standard stuff before (from repositories), and for GCC, you don't have a choice since you need a compiler to compile the compiler!

For general guidelines, I think I explained this recently in another thread, but here it is again. In Linux (or any Unix variant), there are a number of folders where applications and development libraries get installed:

  • /usr/bin : where top-level executable programs or scripts are put (i.e., when you execute a command like gcc, it fetches the executable /usr/bin/gcc automatically).
  • /usr/share : where you find all the "application data" for all the applications installed (e.g., icon images, docs, etc.).
  • /usr/lib : where you find all the compiled libraries (static or dynamic) (more or less equivalent to Windows' "System" or "System32" folders).
  • /usr/include : where you find all the header files (C / C++, whatever else) for the libraries. …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Xerox

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I don't think you can ask for anything more than all the resources already listed on cmake's wiki page.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

It's when we start labeling all people based on stereotypes that we get into serious trouble. Stereotypes are based on what "they" (other people) say and it's always easier to let other people do our thinking for us.

I agree. To me, it's all about Bayesian inference. It's OK to have some a priori ideas or stereotypes about some people or some culture, as long as you know that these a priori ideas are weak and subject to change as you are faced with real life evidence / experiences. For instance, I've never met a Portuguese person, but have heard many times (mostly from Spanish people) that Portuguese people are crazy (wild, party animals, etc.), well, I guess they might be in general, but I really won't know until I've met plenty of them or lived there. Each encounter also has to be taken with a grain of salt because of the variability between individuals, each weighting in a little bit until some vague averages establish themselves. Mathematically, this is called "Bayesian inference", and philosophically, it's called "reason".