The question is very muddled, as it seems to be mixing unrelated topics - the technologies for developing a coupon system (whatever you mean by that, as it isn't entirely clear if you are talking about transferrable discounts or something else; also, note the spelling of 'coupon'), the legal requirements for a coupon system, and the tax code in your local jurisdiction, just to name a few.

As rproffit stated, the best person to discuss the legalities of such a system would be legal counsel (presumably one specializing in contract law as it applies to transferrable discount coupons), not a technical forum. Similarly, the issues of tax codes would be better referred to a CPA, or more likely, a lawyer specializing in tax law (which is a very different topic from contract law vis a vis discounting, which means you'd need to talk to two lawyers at minimum).

None of which relates to the technical side of how to compute the tax applied to these discounts, though you won't be able to write your code for that without speaking to those experts first.

The statements and questions regarding the technology used are, to be blunt, baffling to me. They are so general and uninformative that there simply isn't any substance to what you've said which I can comment on. Could you please explain your intended design in greater detail (without revealing any proprietary information, of course)?

rproffitt commented: To me the tax angles are not muddled as we know to get with our tax attorney. The rest? Muddy. Coupon sites are free here. +15

Please don't resurrect long-dead threads like you just did. It is very unlikely that the people you are replying to are still on Daniweb after 8 to 9 years.

As for the answer to your question, we will need more information. What version of MASM (or any other compatible assembler) are you using, and do you have the Kip Irvine library and include file in question? What development environment are you using (you mentioned a memory window, and given the topic, I would guess Visual Studio, but that's not a given)?

Also, what data are you trying to pass to DumpMem, and how? The code for this port of the library to NASM for POSIX systems shows the following passing convention (which is the same as in the original Irvine library):

; Writes a range of memory to standard output
; in hexadecimal.
; Receives: ESI = starting offset, ECX = number of units,
;           EBX = unit size (1=byte, 2=word, or 4=doubleword)
; Returns:  nothing

Could you post the code you have tried to run, please?

Hmmn, that is the most recent version, so you should be fine. My concern was mostly that you might have had an older compiler, and might have wanted to upgrade if it were.

nathan.pavlovsky: I know that you have the explanation, but the question itself may indicate a possible problem. I say this because it used to be common for compiler packages to cross-include headers in order to support older code, but most newer compilers' libraries have eliminated most or even all of these cross-inclusions. Running into a cross-inclusion issue is uncommon (but not unheard of) in recent releases of most C/C++ compilers. Which compiler (and IDE, if any) are you using, and what is/are the version number(s)?

I think a more basic explanation may be called for...

Like most languages still in use, C++ is still evolving over time, and the official standards for the language is updated by the International Standards Organization (ISO) and the American National Standards Institute (ANSI) at irregular intervals as the development committees set the changes into the rules. The different versions of the language - which generally are backwards compatible with older code, but add new features and clarify the details of older rules - are given by the name of the agency that released it, the name of the language, and the year it was released. For example, ANSI C 89 was the first 'official' standard for C, released by ANSI in 1989. The current standard most C++ compilers support (at least partly) is ISO C++ 11; since ANSI accepts the ISO standards for most programming languages as the same as their own, the 'ISO' part is usually dropped, so it is called C++11. There is a newer update, C++14, but it is a minor update for the most part (mostly clarifications of problematic parts of C++11) and most C++ compiler developers haven't gotten to working on supporting it yet.

You'll also note that most C++ compilers are also C compilers, so you want to make sure that you are compiling for C++ for this class, not C.

Thnx for your replies....actually i am B.TECH in computer science.

I assume that you mean that you have actually graduated with said degree, rather than that you are currently a student. Unfortunately, that still tells us little about your programming ability, as quite a few people graduate with Bachelor's, Master's, or even Doctoral degrees who have no skill or knowledge of the field they allegedly are accomplished in, and sadly, it is possible to go through an entire career in high-paying positions without learning a thing as well.

As for your question regarding DLLs, as has already been said, we would need a lot more context to determine what, if any, relevance they have to your project. since you are working in Java, the most obvious answer would be 'none at all', but it all depends on factors we don't know.

Dynamic Link Libraries are a feature of Microsoft Windows which allow native code libraries to be shared in system memory by multiple processes running simultaneously; the same feature is called 'shared libraries' in Unix-like operating systems such as Linux or MacOS X, but in all cases, the support for them is specific to the particular operating system.

Now, one of the primary aspects of Java is that it does not run native on any operating system; Java programs compile to a bytecode that is either run directly in the virtual machine, or is further compiled to native code by a Just-In-Time compiler that is managed by the virtual ...

Asking for help in an illegal activity is a violation of Daniweb forum rules, specifically:

Do not ask for help to pursue any illegal activity including, but not limited to, hacking and spamming

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 us what you've done, what you've tried to do, and what problems you've had with it, then we'll be happy to help. If you have specific questions, we can answer them, or at least point you in the right direction. If you have a program with a bug you can't swat on your own, we'll be glad to assist, so long as you pay attention to the forum rules and post sensible questions in an intelligent manner that we have some reasonable hope of answering.

But just cutting and pasting an assignment into a message, without even prefacing it with something like, "I have this homework problem that I can't solve...", is likely to get you booted from the message boards here and elsewhere - if you're lucky. What happens to you if you are unlucky is... well... let's just say that this guy probably won't be trying that again, on that forum or this one.

We take this issue seriously here. Very seriously. Asking us to do homework for you is a grave breach of academic ethics on your part, and actually doing so would be an even bigger breach on ours (not that this stops the many fine ...

Again, I would need to see both the function you have written, and the error message you are getting, before I could have any hope of answering that question. Sorry to harp on this again and again, but you need to give us all the information needed to understand what is going on with your program.

OK, first off, you are never setting the value of ans, so ans is by default zero. Any answer other than 0 will fail.

As for why it never gets to the esle part, the answer is simple: you have dupicated the if() condition one successive lines. Correctly indented, it looks like this:

         if(num2 == ans)
            if(num2 == ans) {
                System.out.println("answer correct, excellent!!!");
                int numtries = 1;
                scores = 10;
            else {
                System.out.println("incorrect, \n try again");
                scores -= 5;

The effect of this is that the first if() always is false, so the second if() - which is the one with the else clause - is never executed.

This would have been clear if you had indented the code in a consistent fashion. While which indent style you apply is your choice, consistency in indenting isn't optional. You might want to see if the editor or IDE your using has an auto-indent function, and see if that helps. BTW, just out of curiosity, which editor are you using? Someone here may know if it has such a feature, if you aren't sure yourself.

I would add that you're going about this the wrong way - it is clear you have misunderstood the assignment. The goal isn't to have the user guess the numbers, but to put them in order. What you need to do is show them the numbers in the order they were generated, then ask them to repeat them in order from lowest to highest. ...

sigh I need you to paste the exact error message into a post so we can see it.

We still would need to know what the syntax error is, not just where it is occurring.

As for the second part, you are setting array_size to zero here:

int array_size =0;

Then you are comparing i < array_size. If i is set to zero, it isn't less than zero, is it?

You want to set array_size to the total size of the array. So, if the array is meant to have five elements, you would set

int array_size = 5;

That's the size of the array, not the index of it. The whle idea is that you are counting up to 4 (which is the highest integer below 5, naturally), so array_size indicates the endpoint of the loop iteration. Mind you, you want to declare array_size as final (that is to say, constant), and use it when you construct the array:

final int array_size = 5;

int[] rand_array = new int[array_size];

This gives you a fixed, named value for the array size, so that if you ever need to change it, you only need to change it in one place.

Can you post the error messages you are getting, please?

decorators only work on function call, not on definition

Actually, they can be either one, sort of; the decorator syntax is just syntactic sugar for calling the decorator function with the defined function as its first argument. That decorator function can be any higher-order function that takes a function as its first positional parameter, and returns a function as its only return value.

Defining a decorator operation that is invoked at function call requires wrapping the defined function in a closure, and returning the closure as the value of the decorator, but the decorator itself runs at define time.

basically, what I want to do is add a function name to an outside reference in a safe sys.modules reference without copying the name...

Have you considered writing a decorator? Perhaps something like so:

def myfunc(args):
    x = None
    return x

You could even set it up to allow multiple registries:

def myfunc(args):
    x = None
    return x

I'm not quite sure how you would implement it, but that seems like the most reasonable approach to take, given the semantics you want.

Gribouillis commented: Of course +14

How am I supposed to accomplish this. How can you create an arrays that could store arrays so that it can compare random numbers

If I am reading this correctly, what you are looking to do is have two arrays - one holding the random numbers, the other holding the user input - and compare the results from each, correct? Well, the first step would be to declare an array (obviously), and populate it with the random values:

    final int MAX_SIZE = 5;

    int[] rand_array = int[ARRAY_SIZE];

    for(int i = 0; i < ARRAY_SIZE; i++) {
            rand_array[i] = (int)Math.random() % 16;

Note that the first element of an array is element zero - an array of 5 elements would go from rand_array[0] through rand_array[4]. Thus, you should be initializing i to zero, as I have above.

Also, I am pretty sure you meant to use modulo 16, not multiply by 15. Using modulo this way will limit the range of the random numbers to 0..15. It isn't the best way to do it - it tends to bias the values to the lower end of the range - but it should be adequate.

A better solution would be to use a Random object instead:

// declare this before the for() statement
Random randomizer = new Random();

for(int i = 0; i < ARRAY_SIZE; i++) {
    rand_array[i] = randomizer.nextInt(MAX_RANGE);

Where MAX_RANGE is the maximum value in the range (15, in this case). You will need to import java.util.Random ...

Erk, I did it again - I was editing my post, adding details and clarifying some points, when you answered me. You may want to check what I added to it.

I keep getting an error for "password was not declared in this scope" in main.

As tinstaafl pointed out already, that is because password isn't declared in main(), and in any case you are using a C-string (a zero-delimited character array, as used in the C language, the predecessor of C++) instead of a string object (a class that is specific to C++, which is recommended when working with new code in C++, and what the assignment actually asks for). C-strings aren't so much a type as they are a convention for how to use a char array to hold strings; I'll explain what I mean by that a little bit later.

So, what you want to have is a declaration for a string in main(), which you would read in from the console in main() and then pass as the argument for IsValidPassword().

One of the principles of code design is the separation of concerns; that is, you want to have the code for communicating with the data source (e.g., a text shell, a windowed user interface, a database) separate from the code which processes the data (e.g., computations based on the data, validation tests, etc.). This makes the logic of both sections easier to understand, makes the sections more modular, makes the interfaces between the sections clearer, and makes it so the computation isn't bound tightly to the I/O. For example, if you write your validation function so that it only gets the data from its arguments, and ...

TObannion commented: Very explanatory and in depth. Thanks +1
Slavi commented: wow .. +6

I think you'll find that it was AH, and that you wanted to set that to 4Ch; however, since AH is the high byte of AX, using MOV AX, 4C00h is the same as assigning MOV AH, 4Ch followed by MOV AL, 00h. The effect is (almost) the same, since you were returning a zero to the shell anyway (zero is used by the shell to indicate a successful completion of the program), but this is misleading; for other interrupt calls, you will sometimes need to pass an argument through AL, and if you had set AX instead of AH, you'd have a serious problem. In this case, it works out (and even saves an instruction, technically speaking), but you should be aware of why it works, and what is really happening, in order to see the potential problems in that approach.

Hanif1993 commented: Yeah +1

I think you misunderstood what stultuske was saying. What he means is that then you post to Daniweb,the code section and only the code section should be pasted into the message using the Code button, while the actually text of the message should be entered with the normal editing window.

Just to clarify the issue, Markdown (the format used by Daniweb) automatically puts anything indented by four or more spaces into a code sub-window. So, if the text is indented, it will show up as code, even if that isn't what you intended. So, when adding a section of plain text, always make sure that the text is not indented, but the code is.

So, for the code you posted, it should look like this:

        Scanner keyin = new Scanner (;
        Random randobj = new Random();

        int user1age, user2age,count = 0;
        String user1name, user2name;
        int ans = 0, scores = 0;

        System.out.println("Hi Welcome Students!!!");
        System.out.println("To the school of counting numbers!!!!");
        System.out.println("This school will teach you how to count numbers");
        System.out.println("I am going to implement a game of counting but will need two players");
        System.out.println("Is there anyone who is interested");
        System.out.println("The rules of the game goes like this");
        System.out.println("The players must between the ages of 5 and 10");
        System.out.println("They must not be older or younger, the comprise of three attempt");
        System.out.println("Each players is given three chances to get the correct answer and if not the game goes to the second players");
        System.out.println("Do you students think that you are up for the ...

Well, aside from the fact that 4C00 hex is far too large to fit in to fit into a byte (the maximum value for a single byte - that is to say, 8 bits - is FF hex, or 256 decimal), a quick check of Ralf Brown's Interrupt List's entry for interrupt vector 21h shows no parametric function for 4C00h. Are you sure you didn't want (INT 21h, AH=4Ch)[] (exit with a shell return value)? That would be the usual function to call at the end of a MS-DOS program, IIRC.

You'll have to give us a good deal more detail about the problem, I'm afraid. What kind of constant are you trying to use? I assume it is an integer, in which case you probably don't have many options - Turbo Assembler (which is the TASM I assume you mean - there were at least two others which went by that acronym) was a 16-bit real mode assembler for MS-DOS, and did not work directly with values greater than FFFF hex (65536 decimal). There are ways to work around this, but they aren't particularly easy.

Which leads to the next question: why TASM? is this for coursework (in which case you probably don't have any choice), and is there a reason why it is in an archaic 16-bit assembly dialect for MS-DOS? Current versions of Windows (Vista and later) won't even run 16-bit real mode programs except through an emulator such as DosBox; if you have any choice at all in the matter, I recommend that you ditch TASM for a modern assembler that actually still runs, such as NASM or FASM.

Actually, this is what I believe is now called 'C++ for .Net Applications', what used to be called 'Managed C++' (or as I always preferred, 'Mangled C++'). It is a dialect created by Microsoft and specific to their systems, which runs on the .Net CLR. It is really a new language, distinct from standard C++, but MS never wanted to admit this as it would put off those who didn't want to work with .Net (and to silently lock client-programmers into their non-standard dialect without them realizing it). It exists primarily because they were never able to move all the system operations to .Net as they originally planned, and so continued to need ways to mix .Net code with native code (as I understand things, their real goal in creating .Net was to give the x86 platform the heave-ho - something nearly everyone, including Intel, would like to do - by making Windows itself run in the .Net pseudo-machine a la the old UCSD Pascal OS, but it never came close to working since it would mean losing the entire backwards compatibility structure that Windows' success is built upon, and the goal was eventually abandoned).

OK, rather than getting caught up in the details of the specific matter, let's talk basic principles for a bit.

The main purpose of inheritance is to allow common elements of two or more classes to be defined in a way that the child classes can share what is defined in the parent class. Let's say you have a class Vehicle, which defines - without regard to the mechanism - a method move(). Now, if you want a class Automobile that describes the properties and behaviors of a car, you need not define an entirely new class; you can inherit most of what you need from Vehicle, including the move() method. You can override the existing move() method or not, depending on how you want it to behave. You can also add new methods, such as brake(), to extend the abilities of an Automobile beyond those of the parent Vehicle class.

Now, here's the important part in regards to your question: since an Automobile is an instance of a Vehicle (given our definition of Automobile), you can have any Vehicle instance hold an Automobile as a kind of Vehicle. Because it is a Vehicle, any method that is common to all Vehicles can be applied to the variable, including move(), and it will correctly use the version of the method for the actual object's class. In other words, even though it is a Vehicle variable, since the object is an Automobile, it will use the move() for an Automobile, if ...

I am guessing that you used the built-in float type for this, but given that you are dealing with currency, I would recommend using the decimal module for representing the monetary value instead, to get the best control over the significant decimal places, and applying locale.currency() to format the value as a string. While the links I posted are for the Python 3.4 docs, thhis should apply to Python 2.7 as well.

Before I get to my answers, let me ask you a question: what is your purpose in accessing dev/urandom? Is this for a class assignment, or part of a larger project? Is there a specific reason why the usual srand()/rand() functions aren't sufficient? What are your goals in doing this?

OK, now that that is out of the way, here goes. The first thing to know is that /dev/urandom (and the files in the /dev directory in general) isn't actually a file at all; it is a pseudo-device, a sort of handle for accessing the kernel pseudo-random number generator in this case.

To read either /dev/random or /dev/urandom, you need to read in a block of one or more bytes (type char is usually used, though using uint8_t might make it more easily understood that the buffer is being used for it's numeric value), which you would then pack into the integer either by using shifts, or by having the buffer as a union of two overlapping buffers:

#define INT_BUF 32 
#define BYTE_BUF (sizeof(int) * INT_BUF);

    uint8_t buffer[BYTE_BUF];
    int rand_values[INT_BUF];
} random_buffer;

This StackOverflow thread explains how to read from /dev/urandom effectively, including why you might want to read several values at once. Note that in one of the later answers, it is explained that you ought to check to make sure that dev/urandom hasn't been spoofed to /dev/zero or something similar before reading from it.

The difference between dev/random and /dev/urandom is that random blocks when it ...

The elaborate on DaveAmour's answer, you should know that C (the predecessor of C++) does not have a built-in boolean datatype, and until the C99 standard didn't have a standard defined one either. Thus, it has long been the convention in C to use int variables as booleans, with 0 for false and any other value for true.

While C++ has always had a bool type, a lot of C++ programmers who had started out in C never got into the habit of using it, and a lot of C programs which were converted to C++ were never changed to use it, either.

The variable name flag (or some variation thereof) generally indicates that the variable is being used as a boolean value, and more specifically, a flag value, that is, one used to indicate a particular state or state change in the program. In file formats, an int value may actually hold several packed flag fields, with the individual bits being treated as separate boolean values. However, in the context you are describing, it is more typical for it to hold just a single boolean value.

respectfully you don't have any right to notify of which country I belong to and what are our professors teaching us?

I apologize for overstepping on this matter, then. Your location is posted in your member profile, but you are correct, it was inappropriate for me to point it out.

As for what your professors are teaching, that was meant as a warning to you that what you are being taught is at least partially invalid, and to be aware that your coursework is likely to give you little traction in modern programming.

Let's see, old style headers with extensions, <conio.h>, void main() - let me guess, your professor is using Turbo C++ as your compiler?

/me checks OP's locations Ah, Pakistan, that explains that. This comes up a lot, and the answer is that there's nothing to be done about it. Pity, there's really no chance of you being allowed to use something more modern there, as the university system in Pakistan (like that in India) standardized on Turbo C++ decades ago and won't budge an inch on the subject. It's unfortunate, as it means you are being taught a version of C++ that is nearly twenty years out of date, and using a compiler so old that you can't even install it on newer PCs without using a DOS emulator, but as long as you are going to class at a university in your country, there simply isn't any alternative.

The first piece of advice is to be more careful with indenting your code. Proper indentation makes a world of difference in how readable the code is. The specific indent style is less important than being consistent about it; the whole point is to make the different parts of it stand out.

The other thing is that, no matter what the compiler accepts, and no matter what your professor may have told you, void main() is not valid C++. In C++, the main() function must always return an int, either zero when the program succeeds or an error code when it ...

There's a lot of (well deserved) hate for goto, but it's not inherently broken or bad.

True; there are places where it is justified, and where it makes sense to use it. However, such cases are few and far between. More importantly, it takes some experience to know when it is reasonable to use it, which is why novice coders are generally steered away from it. The goto statement is very powerful, more powerful than is usually necessary, and that power takes discipline to use effectively.