3,183 Posted Topics
Re: > HI everyone ,In this semester i have a course on data structure , My teacher is going to recomend us C# or C++ for implementing structures . i have good skills on c language and java but dont know C# and i hate c++(however i have learnt some bit … | |
Re: > If I write a C++ program and compile it into an executable file AND, don't have to install the program, will I have trouble running that C++ written program on other platforms? Yes, you probably will. The executable itself is specific to the operating system and chipset where you … | |
Re: $table1 = "<div id=\"container\"><table id=\"table-3\" cellspacing=\"0\"><thead><tr><th>Totalt</th><th>" . $Totalt . "</th><th>Benchmark</th><th>Differans</th></tr></thead><tbody>"; | |
Re: When you open a stream and then read to the end, it doesn't magically reset to the beginning at the programmer's convenience. In fact, it stays right where you last stopped reading. You need to clear the error state (because it will be marked as end-of-file) and reset the get … | |
Re: How are you storing the graph? That kind of matters in the implementation. ;) Another critical factor would be whether there's a cycle in the graph or not. It's simpler if you don't have to consider revisiting a node. In fact, if there are no cycles then you can probably … | |
Re: > size_t //Eerm, what is size_t? It's a typedef for an undisclosed unsigned integer type (usually int or long). It's defined in <cstddef> along with a number of other C-inherited headers, and the intended usage is as the result type of the `sizeof` operator. Since `sizeof` is often used to … | |
Re: If by "help" you mean "do it for me" then no. If you want actual assistance rather than a hand out, then please ask a specific question. | |
Re: You can't use the == operator to compare arrays. Well, you *can*, but it almost certainly doesn't do what you expect or want. Ideally you'd use a std::string object instead of an array of char for strings, because then the == operator is overloaded and does what you want. Otherwise, … | |
![]() | Re: > I came across this program in the C++ section. How to do something similar in C? While that program is indeed written in C++, the conversion to C is trivial as the overall structure doesn't depend on anything specific to C++. The library being used is Windows' Win32 API. … ![]() |
Re: Is it airline reservation homework time of year already? Oh, how the year flew by. :D | |
Re: > It compiles and runs up until the first function is called then crashes I'm surprised it compiles. What compiler are you using? Anyway, there are a number of problems with your code such that it would be faster to give you a good example instead of enumerate the existing … | |
![]() | Re: Good hackers know how to program their own exploits and tools. Bad hackers, also known as script kiddies, mindlessly use exploits and tools written by good hackers. This is all using the negative connotation of "hacker", by the way. |
Re: Dani and I have been discussing it furiously for the last couple of days. Hopefully we'll have an idea of what's causing it soon. | |
Re: > Is it clear now? Very clear, but C++ isn't suited to this kind of dynamic programming. A better solution would be to return a reference to the object rather than the name of a variable (which is lost during compilation). | |
Re: Your best bet to simply ask questions, and everyone who answers can be your mentor for that thread. | |
![]() | Re: We could probably do it dynamically with a profile setting, but I think Dani is very much against plain text in the editor given that its highlighting capabilities are one of the primary reasons we chose it. Is there anything broken with the highlighting such that you want to turn … ![]() |
Re: This isn't a trivial exercise. Do you have a specific question? | |
Re: > AFAICT, we've unfortunately lost the ability to close threads... As a moderator you can close the thread by editing it and checking the "This Article is Closed" check box. | |
Re: When testing sort routines visually I'll usually use a before and after printout: void quick_sort (int *a, int n) { if (n < 2) return; int p = a[n / 2]; int *l = a; int *r = a + n - 1; while (l <= r) { while (*l … | |
Re: > but what if question arise to reverse the link list without using pointers? Is it still a singly linked list? Are you allowed to create another variable or data structure to hold the reversed data? Is this a hypothetical question? ;) | |
Re: I wouldn't include print statements in these functions, as that limits flexibility. Rather, they should return some sort of error status (NULL is a common option). > Is it necessary to free the memory of the node that is deleted? Yes. | |
Re: > Why do you think there are soo many programming languages? Off the top of my head: * Because one size doesn't fit all, and different languages suit different purposes. * Because computer science continues to evolve, and yesterday's language may not be suitable for today's needs. * Because programming … ![]() | |
![]() | Re: > Why does the following snippet produces different result than expected? Undefined behavior was invoked. Your expectations are invalid. http://en.wikipedia.org/wiki/Undefined_behavior http://c-faq.com/expr/evalorder1.html http://c-faq.com/expr/ieqiplusplus.html |
Re: > Searched all over the internet but all the programs provided are not working!! You could try to understand the algorithm and write your own, or strive to make the programs you found work...but that might be too much to expect from today's programming students who seem to want everything … | |
Re: You have no choice but to allocate new memory and copy the data pointed to by the pointers. The most robust way to do this would be to write a copy constructor for each of the structures that needs to handle a deep copy. And of course, when you write … | |
Re: Input using the >> operator is delimited by whitespace, so by default you'll only read the next "word" in the stream. If you want a full line, use getline(). | |
Re: > So why does this happen? If you try to call an explicit constructor with an implicit expression then obviously it's going to fail. That's what `explicit` means. | |
Re: > Initially, this was a quick and dirty way to do this, and worked well, but it's turning out to be quite unwieldy now with all the if-statements. I'm sure there must be more intelligent ways of doing this. It's funny that right as I hit the "huge list of … | |
Re: Those names are stored as strings within the thread table for maximum efficiency. Updating them when making a name change would be unreasonably expensive (since we'd have to go through *every* thread from the beginning of time), and storing a link to the actual user to get the name would … | |
Re: First step: check to see if malloc() failed before dereferencing ptrCand: Cand* ptrCand = (Cand*)malloc(sizeof(Cand)*rows*cols); if (!ptrCand) { cout << "malloc() failed!" << endl; } else { ptrCand[16*1024+16].status = 0.5; /* exception happens here*/ } | |
Re: I'm not sure I understand what the problem is. Can you describe it in a different way? | |
Re: > Why should I override my constructors or add a move/copy to this class as the compiler suggests? As the compiler suggests? I assume you're getting a warning to that effect, what does it say? | |
Re: > x += buffer.str; // Problem str() is a member function: `x += buffer.str();` > double y = atof(x.c_str) * Multiplier; // Problem c_str() is also a member function: 'double y = atof(x.c_str()) * Multiplier;' Repeat that fix for every usage. | |
Re: [Click Me](http://eternallyconfuzzled.com/arts/jsw_art_bigo.aspx) | |
Re: A heap is *like* a binary search tree, but it isn't one. The heap property is less strict in that you can't tell from the current node whether to search the left or right subtree. All you know is that the item in the current node is a match, couldn't … | |
Re: > What is this new system we're talking about? It's uniquely Daniweb's. Dani and I wrote it from scratch over the course of last winter. > Absolutely LOVE the new Daniweb... Thanks! It's nice to get feedback, but positive feedback is better for the ego. ;) | |
Re: The editor resizes as you edit your post. I've found that it's not perfect and you may end up scrolling a bit in some cases, but it does at least attempt grow and shrink to fit the content. | |
Re: I see three potential alternatives: 1. Keep the live preview, but let us toggle it with a check box (and remember the choice). 2. Keep the live preview, but let us toggle it with a profile option. 3. Ditch the live preview in favor of a preview request (perhaps in … | |
Re: > (1) means that there was something wrong. While 1 can be an error code, the whole point of using 0 to signify success is because there's only a single success value but a large number of potential error values: anything in the range of int that's *not* zero. So … | |
Re: [Click Me](http://net.tutsplus.com/tutorials/php/how-to-create-a-phpmysql-powered-forum-from-scratch) The concept of a discussion forum is actually pretty simple, and a bare bones forum system is equally simple. Adding in other features, scalability, compatibility, and security are what take up the lion's share of effort. If you have any specific questions about how Daniweb in particular works … | |
Re: You don't clear `command` anywhere in that snippet. If it's not cleared anywhere else, then I'm not surprised that the previous data remains. After each iteration of the outer loop you can just say `command.clear()` to make it empty. | |
Re: > I'd like to respond to a poster, but i get a red warning about a code snippet being not correctly formatted. There is no code in my post, just some log references and a URL. I think that's due to a perceived indentation, which is matched as a false … | |
Re: > It has just come to my attention that he has indeed used this for spam. He is also using it for profit too. > > Would this not be considered a breach of forum rules? It's soundly in the gray area as far as self-promotion goes, but I think … | |
Re: In your case (being a moderator with unlimited edit permissions), I'd say just keep a running update on the code for the snippet and make sure to include an easily seen comment in the message that says the code snippet is evolving. You might also link to the thread in … | |
Re: It depends on what you're looking for. The same question might be asked about string comparisons, or array comparisons, or binary search tree comparisons. However, typically a comparison means comparing corresponding items. So you'd traverse both lists and compare the data in each node. When they don't match, you return … | |
Re: The problem was the {...} delimiters in the post. It looks like Dani added a code validation rule to account for weaknesses in the editor's highlighting algorithms, and it explicitly disallows braces for some reason. I'm not sure what the reason is, as we've disabled the only place in Markdown … | |
Re: > But there is no way to traverse a singly linked list backwards. Incorrect, and if you had read this thread more carefully you'd see at least two replies (one from mike_2000_17 describing the process and one from Schol-R-LEA with sample code) showing an easy way of doing what you … | |
Re: In C++ you can certainly pass an array directly by reference: #include <iostream> using namespace std; void foo(int (&a)[10]) { for (int i = 0; i < sizeof a / sizeof *a; ++i) { cout << a[i] << '\n'; } } int main() { int x[10] = {0, 1, 2, … | |
Re: func() must be a member function of the class type for xx and return an object or reference to itself so that the the same member function can be called on the result. One example might look like this: #include <iostream> using namespace std; class Foo { int _value; public: … | |
Re: Um...what? What do you mean by "get name mangling". Name mangling is an internal method for compilers to differentiate between otherwise similarly named objects. It's not something you as the end programmer need to care about except as pertains to disabling it for C compatibility. |
The End.