1,359 Posted Topics
Re: **1-Q1.** It would be easiest to give an example, rather than explain it. Let's say you have the files foo.h int foo(int x); int bar(char* str); foo.cpp #include "foo.h" #define QUUX 23 int foo(int x) { return x * QUUX; } Then when the pre-processor has gone over it, the … | |
Re: There are several [unit testing frameworks](https://www.google.com/search?q=unit+test+framework) for each of those languages; an extensive (but not complete) list of them can be found [here](http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks). Of the ones for Java, far and away the best known is [JUnit](http://junit.org/). It is derived from the original Smalltalk SUnit testing library, and strongly influenced several … | |
Re: OK, aside for the fact that the function header should be `int main()` and not just `main()`, what is the problem you are having? | |
![]() | Re: Actually, no. There are definite limits to computability. Look up [Alan Turing](https://www.google.com/search?q=alan+turing) and [the Halting Problem](https://www.google.com/search?q=halting+problem) for one well-known example of an undecidable proposition. |
Re: As a matter of kindness to you (and anyone else reading this), I'll post the existing code properly indented; however, no one here is going to fix the problem for you. We will give advice, but not free homework answers. In any case, the answer was already given to you … | |
Re: OK, let me see if I have this correct: what you want is for to provide a timer which will wait either for *n* milliseconds, or until a key is pressed, correct? It sounds to me as if what you really need is to use a separate thread for the … | |
Re: In the future, please use the 'code' menu button at the top of the editing window to paste in code samples. By default, the forum software does not retain indentation, which makes reading Python code especially difficult. As it happens, the causes of the problem are plain to see. First … | |
Re: While I share stultuske's misgivings about external links, I went ahead and looked anyway - foolish, perhaps. Anyway, I noticed something that would not be evident if you had simply posted the code here, so you are fortunate that I did. What I noticed is the compiler output that follows … | |
Re: OK, I can see your getting flustered, so let's back away from the code for a bit and consider the overall problem you are trying to solve. Just what is the program supposed to compute, and how would you do it by hand if you had to? I don't mean … | |
Re: While it is certainl;y more an intermediate to advanced level project, you might consider going through the [Scheme from Scratch](http://michaux.ca/articles/scheme-from-scratch-introduction) process. It not only is a nicely incremental project, meaning that at no one point should you get overwhelmed by it, but it also exposes you to a radically different … | |
Re: Aside from the fact that you are asking us to do your assignment for you (as it is a rather simple one, really), you haven't given enough information to solve it, as it depends on the contents of the memory at address 2000:0004 (technically, it also depends on the specific … | |
Re: **@Deceptikon:** While your suggestions are well thought out, they really don't apply to the MIPS architecture, which works significantly differently from the x86 architecture, especially with regards to using the stack. Among other things, the standard word size is either 32 or 64 bits, depending on the model of the … | |
Re: It is pretty clear that you got this code from the [TKInter tutorial](http://www.pythonware.com/library/tkinter/introduction/hello-again.htm) and made the simple modification of trying to substitute a `Button` with an `Entry` box. Fair enough; that sort of thing is part of learning any new API. In this case, it didn't work out. It happens. … | |
Re: Well, it's not so much that (especially since 60 lines isn't all that much) as it is the tendency of newcomers to simply post their code without actually asking a question about it. In this case, we'd also need to see where you are setting `c_num`, as well. | |
Re: Does `gfunc_Realloc()` work correctly elsewhere? Have you tried writing a simple test program to check if the `gfunc_Realloc()` function behaves correctly in general (that is to say, when given some test data, it works correctly)? For that matter, are the `gfunc_Realloc()` and `gfunc_memAlloc()` in a separate compiled source file, or … | |
Re: I believe that what you are looking for is the `import` statement. If you have a Python file, say *test.py*, and wish to run the program in that source file while in the interpreter prompt, you can enter import test and, provided that the file *test.py* is in the same … | |
![]() | Re: The problem is that you aren't resetting either `count` or `totalGrade` before beginning the second loop. also, in both loops, you can (and probably should) move the calculation of `average` out of the loop body. I think you'll also have a problem with the second loop's end condition, as you … ![]() |
Re: The issue here is that `this` is a pointer to the object as a whole, not just to an array; you would need to access the `string`'s internal array to do this, and since that array is `private`, you cannot do that - at least not directly. What you want … | |
Re: As a matter of fact, I do. However, it would not be very helpful for me to simply give the code to you; learning is the goal here, after all. I will say that you are overthinking things a bit (been there, done that, bought the tee shirt). Rather than … | |
Re: What is the expected result? I suspect that you have misunderstood the last part of the summation formula. I suspect it is supposed to go more like: n ---- \ n 1 + / (-1) n! / (x - n) ---- i = 2 or, 1+2!/((x-2))-3!/((x-3))+4!/((x-4)) - ... n!/((x-n)) which … | |
Re: You would use the `bit?` predicate to test the value first, then if it is a single bit, emit the value unchanged; otherwise, perform the split. | |
Re: You would have to discuss the matter with the original coder to get a definitive answer, actually. It really has nothing to do with the `BufferedReader` c'tor itself, which just takes a filename as it's argument. As for line 3, that's the beginning of an exception frame. You would need … | |
Re: The first step in solving this problem, I think, is learninig to indent your code in a consistent and legible manner; since this is Java, I recommend following the official [Java Style Guide](http://www.oracle.com/technetwork/java/codeconv-138413.html), at least as far as the basics are concerned. import java.util.Scanner; import java.io.*; public class prog166d2 { … | |
Re: Could you please explain what sort of problems you are having with this? | |
Re: *As per request, one boilerplate answer coming up:* 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 … | |
Re: Before addressing your question, I would like to point out some issues with the code as given, ones which may help understand the problem at hand. Before I do, would you mind telling us what compiler and IDE you are using? It may help us understand certain aspects of this … | |
Re: The short answer is, you can't. NASM is specific to the x86 and x86-64 family of processors; you will need a Z80 assembler (that's the processor the TI-84 uses) which produces object code which can be loaded to the calculator in order to program for it. The TASM you mentioned … | |
Re: Macros, like all preprocessor directives, are expanded before the compiler is run; thus, no, you cannot override a macro definition with a C language statement. A bit more explanation may be in order here. When you go to compile a program in C (or C++), you are actually invoking at … | |
Re: [This posting](http://www.daniweb.com/software-development/assembly/threads/424508/disassembling#post1814196) may help explain the purposes behind the stack instructions a little better. | |
Re: The problem is actually two-fold: first, you are loading a value where you need an address; and second, you are trying to write out an integer with a function which expects a character buffer. The solution to the first problem is to change the code so that it puts the … | |
Re: Before we go anywhere with this, I want you to be clear about two things. First, that this is actually two different programs which you'll need to write, and second, that **you** will need to be the one to write them. We can give advice and help, but we cannot … | |
Re: Is there any particular part you are having trouble with? | |
Re: The problem isn't in the comparison, nor in the `je` or `jne` instructions; it is in the declarations for `a` and `b`. For each of those, you define them as a 2 reserved bytes; howvever, the `mov eax, [a]` instruction assumes that `a` is a doubleword (4 bytes), and as … | |
Re: As a piece of advice, I can suggest this: assuming that the language you are indenting is C (or one with a similar block syntax, such as Java or C++), then the simplest solution is: set the indent amount to four set the indentation level to zero for the length … | |
![]() | Re: In the declaration of `struct author`, you define `down` as type `link`, which is a `typedef` for `struct author*`. What you actually want is for it to be a `ptr` (that is, `struct book*`). Thus, you'll want to move the `typedef` of type `ptr` up to before the definition of … ![]() |
Re: First off, you should always use `int` as the type for `main()`, not `void`. While some compilers allow for other return types, the only really correct (in the sense of portable and matching the standard) declaration is `int main()` (or, when using command-line arguments, `int main(int argc, char* argv[])`). Second, … | |
Re: Rather than sharing the code this way, which has some serious disadvantages (no versioning, having to manually cut and paste the code into place, risking overwriting the good code with the older code, etc.), I would suggest finding a source repository such as [SourceForge](http://www.sourceforge.net/) or [GitHub](http://www.github.com) and share your code … | |
Re: The ampersand actually marks the character which is to be used as the hotkey; if you look at the menu as it actually is rendered, you'll see that those letters all are underscored. In the case of 'Exit', the 'x' is the hotkey character (that is to say, if you … | |
Re: What it comes down to is that each state transition can have it's own behavior, represented by a function. In this case, all of the states use the same function to handle the different states, but that is just to keep the code simpler; in practice, you would probably have … | |
Re: As an aside, you will want to use `int` as the return type of `main()` in the future. Strictly speaking, `void main()` isn't legal C++, even if some compilers accept it. Just a piece of advice, which you may need to know about as most newer compilers will flag `void … | |
Re: **Rithish**: The issue is not in the *behavior* of the two forms of the function, but rather is in the wording of the C language standard, and less directly, in the behavior of the majority operating system shells. You see, it isn't incidental that `main()` was type `int` even in … | |
Re: **@Thekilon:** You should check the dates of a thead before posting to it. The original conversation ceased over nine months ago. For the record, in the unlikely case that the original poster is still interested in this thread, I believe that by 'punch cards' the OP is referring to [machine … | |
Re: Assuming you are running Windows, the answer is, you don't. DOS TSRs required low-level access to the BIOS, and hooking an interrupt; they are notoriously badly behaved under Windows, even inside of the cosnole or a DOS box. Under Windows, then the equivalent of a TSR is simply a program … | |
![]() | Re: **EDIT:** I originally thought that this was a different problem, but then I noticed that you were, in fact, reading in a number and not a character. My error. Looking over the code again, it's simply that you aren't putting `break;` statements at the end of each case of the … |
Re: That depends. Just how do you intend to use them? We really would need more detail to give you useful advice. If you simply need a reference, the [this](http://http://www.cplusplus.com/reference/clibrary/cstdio/) should do nicely; while that site is for C++ rather than C, the C I/O libraries work the same in both … | |
![]() | Re: To answer to OP's question, the exact use of bit fields is to allow you to pack several small values into a single integer value, by defining the values in terms of how many bits they need in order to be stored efficiently. As Deceptikon said, they are primarily useful … |
Re: > what code would I have to use in the bootloader to open the second file? That depends on what kind of filesystem you are using, and what executable format the file is in. For example, my own original boot loader simply assumed that the second stage was in sector … | |
Re: The first thing we need to know is what operating system you are running under. For now, I'll assume some version of Windows, probably XP but that's just a guess (***edit:*** your profile says Windows 7. Knowing that makes the rest of this easier.) The next thing we need to … | |
Re: Assuming you are using Python 3.x, then the input isn't going to be a tuple of separate strings, but one whole string. This means that you'll need to use `.split()` on the returned string in order to get the separate tokens. def shell(): in_string = input ('> ') tokens = … | |
Re: OK, we can see that you have these two programs written, but what have you done about the *current* assignment? BTW, three things to take note of. First, you should always declare `main()` as type `int`; while `void main()` is accepted by some older, non-standard compilers, it is not actually … |
The End.