1,359 Posted Topics
Re: As an aside, I have two comments to make. First off, while [indent style](http://en.wikipedia.org/wiki/Indent_style) is largely a matter of personal preference, it is a good idea to adopt *some* form of indentation and use it consistently. It is important for readability, especially as programs grow longer; and while it may … | |
Re: One thing that doesn't seem to have been mentioned is that namespaces are less for projects by a single individual, than they are for integrating disparate libraries and projects by different groups of developers. While namespaces are a boon to a single programmer, they are a necessity to developers working … | |
Re: OK, in that case... actually, you're quite close to it, as it happens. You simply want to have another print line to print a hash before the inner loop, and change the print inside the loop to printing a space: NUM_STEPS = 6 def main(): for r in range(NUM_STEPS): print … | |
Re: I am certain someone can, if you you show us what you've already done on the problem. If you haven't started working on it yet yourself, then I would recommend familiarizing yourself with the [details of the algorithm](http://books.google.com/books?id=JypoXt5hHrkC&pg=PA92&lpg=PA92&dq=hooke+jeeves#v=onepage&q=hooke%20jeeves&f=false) before proceeding. We are here to help you learn. This is not … | |
Re: Using the `input()` function in Python 2.x is generally considered a bad idea, as it will actually evaluate the statement as if it were a line of Python code. This leaves a large security hole that anyone could exploit - if,instead of just a number, the user were to enter … | |
Re: I have to agree with Terminator1337 on this, the code for the `main()` function in particular is wretched (not to mention incorrect - in C++, `main()` should always return an `int`, with no exceptions to the rule). The fact that it appears to have been given to you by the … | |
Re: Could you give us more information about what you need, and what you already know how to do? The problem description is rather sparse, at best. Do you have anything in particular in mind as far as what the program should do? A few questions to get things going: * … | |
Re: First off, you need to recall that Java is case-sensitive. which means that `PackageData` and `packageData` are two different things. The former is the class name, the latter is an instance of the class declared in the `main()` method of `PackageDataTest`. Second, the `toString()` method is something of an exceptional … | |
Re: Unbuffered I/O is operating system dependent; all of the standard C library functions operate on buffered streams. What OS are you running under? | |
Re: There are quite a few problems with this program as it is written, but all of them can be fixed with some patience. The biggest issue I see is that you are reading in the name of the animal to be found, then overwriting that name repeatedly in the condition … | |
Re: Wait a moment, how old is the textbook you are using? While Fortran is still in use - though in a form completely different from it's predecessors - Algol 60 and Algol 68 are long dead. Also, neither Algol 60 nor most older FORTRAN compilers have pointers, or structures for … | |
Re: Perhaps it would make more sense to start with a parent class, Profession, which would have the various attributes in common to all the subclasses: class Profession(object): def __init__(self, name, strength, pilot, intel, stamina): self.strength = strength self.pilot = pilot self.intel = intell slef.stamina = stamina # other methods common … | |
Re: Both answers are accurate, but Banfa's answer is the correct one. Nutster's answer is true in the majority of implementations, but not all, and according to the standard the behavior is implementation dependent. You cannot count on *any* specific result without knowing the implementation in question. As one [famous quip](http://www.catb.org/jargon/html/N/nasal-demons.html) … | |
Re: Your senior consultant seems to be having a senior moment, I would say. This advice is not only wrong, it is dangerous, because VB6 and Oracle 9i are no longer supported by Microsoft and Oracle, respectively, and neither can even be run on an version of Windows more recent than … | |
Re: I should mention that the more conventional solution to this issue is to store a URL or some other sort of path to the image file, rather than the image itself. This avoids the whole issue entirely, as you then would simply access the image file normally. Would this be … | |
Re: Do you know if the DLL a C++/CLI DLL? If so, then calling it directly like this may not be possible. You may be able to use COM Interop to connect to it, but even that isn't entirely certain, if the DLL is 64-bit code. BTW, why do you have … | |
Re: I assume you are referring to and GCC-based IDE such as Code::Blocks or something similar here, correct? Basically, they are two different options for generating the executable, which some IDEs provide as a shortcut. They allow you to have two different sets of compiler options to be set up, one … | |
Re: As pritaeas said, we need to know more about what you're planning on doing. However, as a general piece of advice, I would recommend defining an abstract parent class - let's call it `AbstractBullet` for now - and deriving the different sub-classes of `Bullet` from that. If you do that, … | |
Re: First off, we don't do other people's homework for them. Second, we don't do other people's homework for them. And third, we don't do other people's homework for them. Sensing a pattern here yet? No one here will simply hand you a solution on a silver platter. If you show … | |
Re: Most of these issues come from incorrect nesting. If you look at `main()`, you will see that you have an extra left brace, just after the `using namespace std;`, and that you fail to close the function. This means that you are in effect declaring `MenuSystem()` as two layers of … | |
Re: OK, and what was your question? **EDIT**: The rest of this was incorrect; I had overlooked the fact that `fgets()` stops at newlines. Please disregard. | |
Re: For anyone unfamiliar with the game (as I am), the [Wikipedia article](http://en.wikipedia.org/wiki/Morabaraba) on it is at least a starting point. **phats more:** Can you be more specific about what you need help with? What have you tried so far? What do you know about C#, and what do you think … | |
Re: First off, I would leave the course, as they are teaching you HTML techniques that are thirteen years out of date. No one uses tag properties for presentation anymore, and officially, they've been removed from the language (though most browsers will still recognize most of them). Second off, no one … | |
Re: Anyone who says that the current generation of programmers is in some way inferior to those of the past, is clearly unfamiliar with the programmers of the past. You must recall that until very recently the vast majority - 90% or more - of programmers were COBOL coders, often with … | |
Re: As Moschops said, Code::Blocks does in fact generate a stand-alone program whenever you compile a project. If you look in the project folder, you will find a folder marked Bin, with two sub-folders, called Debug and Release. By default, the compiled program goes into the Debug folder; this is a … | |
Re: As Moschops said, just what 'program analysis' means is going to up to the professor; there isn't really any standard meaning to it. In general, it means identifying the variables of the problem, describing the steps needed to solve the problem, and describing what user input or data is needed … | |
Re: What everyone is tap-dancing around is that, in order to get a consistent result, you need to synchronize the threads. This means that there would have to be an object which has a `synchronized()` block associated with it, which acts as a lock on that object - other threads cannot … | |
Re: > please can you help me,I want to do my homework. Really? Because it sounds like you want *us* to do your homework for you. Sarcasm aside, there is a rule here at DaniWeb: *show your work.* If you want us to help you with a homework problem, you need … | |
Re: My first suggestion is to look into the [csv module](http://docs.python.org/2/library/csv.html) in the standard library. It may save you from reinventing the wheel WRT comma-spearated value files. | |
Re: Is there a specific requirement to use the bubblesort algorithm? With a linked list, an insertion sort would generally make more sense. The main thing you'll want for bubblesort that you don't already have is some kind of `swap()` function. Since it is a singly-linked list, you'll want to pass … | |
Re: While what mike_2000_17 said is all correct, the real reason is actually a lot simpler: C++ has no concept of console I/O because C++ - and many of the operating systems it operates under, including Unices - has no concept of a console. More importantly, C++'s standard libraries operates primarily … | |
Re: Unfortunately, there is no standard way to read and display image files in C; it would depend on the operating system, the windowing manager, and the graphics library you are using. There exist several portable windowing libraries such as Qt, wxWindows, and GTK+, which include the ability to display image … | |
Re: What error are you getting? I assume that `dis` is either an instance variable or a class variable, and thus would be in scope for both methods, is this correct? | |
Re: You would find it much easier to detect many bugs of this sort if you indent the code in a suitable fashion. While it may take some getting used to - it makes the code look like some sort of modernist poetry - it is well worth the trouble. There … | |
Re: Can you please describe this 'too simple' project for us? We can only give advice when we know what we're dealing with... | |
Re: To give a perfectly serious and not at all snarky answer, the first question I have is: why Turbo C? Does the course you are taking require that particular compiler/IDE (I can't imagine any other reason for using such an antique, but I know that many schools in India and … | |
Re: Let's start from, what do you know how to do already? Can you write something very simple, such as a program that prints a line of text (say, 'Hello, World!', to give one well-worn example)? Getting to the assignment at hand, do you know how to write a `for` loop? … | |
Re: Yes, please post your existing code for us, otherwise we won't know how to adivse you. | |
Re: As an aside, if you are taking in case-insensitive user input as you are here, I would suggest using either `toupper()` or `tolower()` to set the case of the switch variable, thus avoiding the issue entirely. | |
Re: The immediate cause of the errors are a) the statement `typeof(n)` in the initialization section of the for loop, and b) the lack of a semi-colon at the end of `f *= i`. However, this ignores a more serious conceptual error (for which the compiler gives only a warning), in … | |
Re: Where is the error occurring? If you post the traceback - the *entire* traceback, please - it should show what line in the code the problem lies in. Also, what is the `search.Problem` class? I wouldn't need details, just a general overview of the parent class so I can better … | |
Re: When you say Eclipse 'fell apart', what actually happened? As JamesCherrill says, Eclipse is generally quite stable, so any catastrophic problem with it is quite unusual and deserves some analysis. | |
| |
Re: What exactly is the behavior? Does it print the shoe data out correctly, or is that also failing? One problem I see is that when you add an element, it overwrites the first one, rather than adding it to the end of the array. You probably want this: //Add new … | |
Re: Assuming you don't need the data after printing it out, I would recommend shortening the code thusly: if andexfield == elem: print andexfield for p in range(1, 17, 2): print p, print for q in range(2, 17, 2): print q, print The third argument of the `range()` function is an … | |
Re: When you say that `import random` failed, just what do you mean? If you got an error message, post it with the full traceback. Otherwise, did it simply not do what you expected it to? I would recommend using the `random.shuffle()` function on the series of questions; however, to do … | |
Re: With the exceptions of inline functions and templates, you do not want to have function implementations inside of a header file. You generally need to separate then out of the header and into a code file that will be compiled. Also, you want to use [#include guards](http://en.wikipedia.org/wiki/Include_guard) around the header … | |
Re: You will, I suspect, find the online textbook [*The Craft of Text Editing*](http://www.finseth.com/craft/) quite useful for this purpose, if only because it gives examples for each of those tasks. | |
Re: Have you tried using either string interpolation or the `.format()` method instead of string concatenation? subprocess.call('echo %s | festival --tts' % (line), shell=True) or subprocess.call('echo {0} | festival --tts'.format(line), shell=True) Also, if you are willing to use espeak instead of Festival, you might consider using [PyTTSx](http://pypi.python.org/pypi/pyttsx) rather than shelling out … | |
Re: Uhm, first off, what language is this in? It certainly isn't standard C++, not unless you've been doing funny things with the pre-processor. Even that wouldn't explain the lack of semi-colons. Is this supposd to be in an actual language, or is it pseudo-code used to explain the algorithm? |
The End.