1,359 Posted Topics

Member Avatar for Jackk123

As is explained [url=http://www.cplusplus.com/reference/clibrary/cstdlib/rand/]here[/url], the maximum value for [ICODE]rand()[/ICODE] (defined as [icode]RAND_MAX[/icode]) is implementation defined, but is at least 32767 for a compliant compiler and library. As for how to get the specific range you want, you need to use a combination of modulo ([icode]%[/icode]) and addition or subtraction. So, …

Member Avatar for Jackk123
0
146
Member Avatar for woody363

There are several libraries available for Linux, some of which I can assure are already installed and others are easily installed from Synaptic. Examples I can think of off the top of my head include [url=http://www.gtk.org/]GTK+[/url], [url=http://www.wxwidgets.org/]WxWidgets[/url], and [url=http://qt.nokia.com/products/]Qt[/url].

Member Avatar for woody363
0
295
Member Avatar for smata

You'll need to give us some idea of what you've tried yourself already. No one in this forum is going to do your homework for you.

Member Avatar for Schol-R-LEA
0
131
Member Avatar for pendo826
Member Avatar for pendo826
0
157
Member Avatar for Wireboy

A few notes: [list] [*] Yes, you would need the [ICODE]<cctype>[/ICODE] header for [ICODE]tolower()[/ICODE]. I could add that you'd want to also have the [ICODE]<cstdlib>[/ICODE] header for the calls to [ICODE]system()[/ICODE]. [*] Are the [ICODE]system()[/ICODE] calls actually needed? If I am not mistaken, Visual Studio 2010 automatically pauses console programs …

Member Avatar for Schol-R-LEA
0
257
Member Avatar for TaoNinja

I agree with Rohan121212; you need to give more specifics about the program. The answer to the question would depend on just how the end of the loop is indicated. If you are given a number of cases to enter before the loop begins, then it is fairly straightforward: [code] …

Member Avatar for frogboy77
0
447
Member Avatar for Yokil

To begin with, please use [[i][/i]code] tags around your code samples. This will cause the forum software to retain the formatting for the code, making it far easier to read. Second, using [icode]void main()[/icode] is incorrect in C++. While the older standards allowed it, it was always non-portable and discouraged, …

Member Avatar for Schol-R-LEA
0
962
Member Avatar for Nikesh2014

Nikesh2014: As Narue says, you didn't actually post a question, which makes it hard to give a useful answer. What seems to be the problem? (Aside from the fact that you are using an ancient compiler, that is. Turbo C++, I'm guessing, given how many schools seem to have standardized …

Member Avatar for Schol-R-LEA
0
134
Member Avatar for Kirbz

First off, permit me to recommend a different representation of the cards, one which would almost certainly be easier to work with: [code]enum SUITS {HEARTS, CLUBS, DIAMONDS, SPADES}; struct Card { int face; SUITS suit; }; Card deck[52]; [/code] Of course, your coursework may not have covered structures and enumerations …

Member Avatar for WaltP
0
287
Member Avatar for RaoxFaello

Let's start by separating the algorithm from the (extraneous) output: [code] #include <iostream> int gcd(int a, int b); int main() { int a, b; std::cout<<"Enter the A Integer: "; std::cin>>a; std::cout<<"Enter the B Integer: "; std::cin>>b; std::cout << "The Greatest Common Divisor of " << a << " and " …

Member Avatar for Schol-R-LEA
0
122
Member Avatar for coroshea

Might I suggest using a reference to a [icode]vector<Pizza>[/icode] rather than a pointer to an array? It would solve most of the issues revolving around pointers and allocation, I think. I realize that it may not be an option with a school project, but if it is acceptable, it would …

Member Avatar for Schol-R-LEA
0
171
Member Avatar for pato wlmc

Actually, it predates computer programming entirely; it comes from conventions in mathematical notation, where i, j and k are traditionally used to indicate the indices of arrays and the iterative variables of [url=http://en.wikipedia.org/wiki/Summation]summation[/url] (big-sigma) operations.

Member Avatar for Tumlee
0
5K
Member Avatar for B031110034
Member Avatar for mc3330418

[QUOTE=mc3330418;1697694] Also, is there a way to write a function and then have it output what is going on in that function? [/QUOTE] Now, I have to ask: just what do you mean by 'have it output'? Where do you want to results sent - to the console, to the …

Member Avatar for WaltP
0
130
Member Avatar for rohan121212

I should point out that Dev-C++ is itself a bit old, as it hasn't been maintained after 2005. Also, neither the [url=http://www.codeblocks.org]Code::Blocks[/url] IDE or the [url=http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express]Visual C++ Express[/url] IDE suffer from this particular problem - both pause the output automatically at the end of a console program.

Member Avatar for Schol-R-LEA
0
100
Member Avatar for nyfan68

You are having the [url=http://www.daniweb.com/software-development/cpp/threads/395461]same problem[/url] that your classmate lbgladson had: you're declaring and defining the functions as [icode]void[/icode], most of them should in fact return a [icode]Rational[/icode] value.

Member Avatar for Schol-R-LEA
0
2K
Member Avatar for rohan121212

First off, you should use [[i][/i]code] tags around your code samples in the future. I expect one of the mods will do this for you, but you should not rely on this, if only because it makes extra work for them. Second, there are a number of issues with the …

Member Avatar for morganJohnson
0
163
Member Avatar for Octet

The code as written isn't valid; unlike in some languages, you cannot have a code block that isn't part of a function in C++. Mind you, it is generally inadvisable to have code (as opposed to declarations) in a header file, but that's not the cause of the problem, per …

Member Avatar for Ancient Dragon
0
1K
Member Avatar for lbgladson

The process is pretty much what you would expect: first you find the Greatest Common Divisor of the two integral parts, and then divide each by that. The result will be the reduced form of the rational number. The easiest way to find the GCD of a number is the …

Member Avatar for Schol-R-LEA
0
6K
Member Avatar for sknn

You're not the first to make this mistake about [icode]fflush()[/icode]; it sounds reasonable, but the problem is that it doesn't do what you are expecting. In C, the [icode]fflush()[/icode] function only operates on output, forcing it to finish immediately rather than remain in the buffer. Applying it to an input …

Member Avatar for sknn
0
142
Member Avatar for s_r_k

Hard-coding is the practice of placing literal constants (e.g., the number 1.0) directly into the program code, rather than holding them in named constants. Repeated use of hard-coded values, or use of inobvious values, is generally frowned upon, as it can make maintenance harder (because if have to change it …

Member Avatar for Schol-R-LEA
0
762
Member Avatar for stillfly122

You can find extensive information, including sample boot loaders, at [url=http://www.osdev.org]OSDev.org[/url]. I would recommend being careful about posting to the fora there, however, as they expect you to carry your own weight, and a blanket request such as this one is likely to get negative reactions. That having been said, …

Member Avatar for NotNull
0
457
Member Avatar for rosey_fci

I am certain that someone here can, if you show us what you've already done first. Doing the work for you, however, would not be considered 'helping' by most of the folk here. (I've actually been criticized for posting too much 'help' at times, rather than giving the original poster …

Member Avatar for sergent
0
175
Member Avatar for bettybarnes

How do you use it for what, and where? the BYTE marker is meant to tell the assembler that you're working with a 1-byte value; you use it to remove ambiguity in places where the value could be either a byte or a word. I don't really see anything like …

Member Avatar for Schol-R-LEA
0
122
Member Avatar for Tcll

While Gribouillis's answer is correct, it could probably use more explanation, because the dot-member notation is used somewhat differently in C++ than in Python and it may be somewhat confusing. In C++, variables have an explicit type, unlike in Python, where variables are typeless (type being a property of the …

Member Avatar for JoshuaBurleson
0
2K
Member Avatar for Zssffssz

This may seem simple, but the question carries with it more than you might suppose. First off, what do you mean by 'a: drive'? This may seem like an obvious point, but it isn't: the meaning of the drive lettering and so on is a feature of the OS itself, …

Member Avatar for miker00lz
0
160
Member Avatar for maria536

You're getting closer with this, but in this case, you do not want the double-quotes around the variable names; double quotes are used to demarcate the beginning and end of a string literal. Thus, you should try the following: [code] cout <<"Encrypted digit:" << digit_three << digit_four << digit_one << …

Member Avatar for maria536
0
190
Member Avatar for cse.avinash

To quote one famous comment made many years ago, undefined behavior could mean that the compiler causes demons to fly out of your nose, if the compiler writer so chooses and is able to implement it. Undefined means just that: that the compiler can give whatever results the compiler writer …

Member Avatar for gerard4143
0
97
Member Avatar for geeksforgeek

Well, the first thing you need to know is that [ICODE]getline()[/ICODE] is not a standard C function (as of the C99 standard, at least to the best of my knowledge). It is an extension added in the GNU version of the stream I/O library, and while it is widely supported, …

Member Avatar for D.M.
0
144
Member Avatar for zendet

Actually, the problem is that you are not enclosing the [ICODE]switch()[/ICODE] block in braces, and as a result, only the first case is being seen as in the scope of the [ICODE]switch()[/ICODE] statement. This is no different than if you had written an if statement like this: [code]if (something) statement1; …

Member Avatar for WaltP
0
4K
Member Avatar for hairo

[QUOTE=sundip;1642648]add return type for BasicLCG(); and BasicLCG(unsigned long); It should solve you first 4 compilation error[/QUOTE] Yes, but it does nothing for the redeclaration error immediately below it. C doesn't allow function overloading; you'll need to give the two different functions different names. Furthermore, those two functions are constructors in …

Member Avatar for hairo
0
740
Member Avatar for asrockw7

To get some of the theory behind this, see [url=http://forums.devshed.com/showpost.php?p=2001351&postcount=14]here[/url]. That discusses the role of linkers and inclusion headers, and how they are used in C and it's relatives. This may help put what Narue said into perspective. While what I wrote then focuses on reusable code libraries, the principles …

Member Avatar for Moschops
0
163
Member Avatar for challarao

Let's break this down somewhat; the increment operator isn't specific to [ICODE]for()[/ICODE] loops, and for that matter, [ICODE]for()[/ICODE] loops don't necessarily use an increment. Let's take the simplest case of a separate increment expression: [code]i++;[/code] Now, whether this compiles to a single assembly language operation or not depends on the …

Member Avatar for challarao
0
145
Member Avatar for ntrncx

You don't have any return value for the case where [ICODE]counter[/ICODE] does not equal 5, so the caller basically gets whatever junk happens to be in the returned value register - and since any value other than zero (false) evaluates to true, the return value is almost always going to …

Member Avatar for ntrncx
0
154
Member Avatar for Nastadon

The main issue I see with this is that you don't have [ICODE]break[/ICODE] statements at the end of the cases. This means that the first case will 'fall through' to the second, which results in the [ICODE]fee[/ICODE] always being set to 20.

Member Avatar for Taywin
0
205
Member Avatar for asitmahato

Actually, AD, in this case it is possible to use Visual Studio as an IDE for NASM; [url=http://justcheckingonall.wordpress.com/2008/03/05/using-nasm-in-visual-studio-6-and-2003net/]this page[/url] explains how to integrate NASM with VS6. It's a bit dated, so some of the details about NASM itself may be off (e.g., paths), but it shouldn't take much tweaking to …

Member Avatar for Schol-R-LEA
0
551
Member Avatar for anders10

I think that the issue the line [code] imul %ecx /* eax = eax*ecx */[/code] Here you should be multiplying by %ebx rather than %ecx, as %ecx still holds a pointer to the end of the string, whereas %ebx should be holding the decimal place which you want to multiply …

Member Avatar for anders10
0
3K
Member Avatar for now how abt tht
Member Avatar for Johnny666

Would you mind posting the class declaration (in the header file), as well? It would clarify a number of things about the code. From what I am gathering, though, the Bullet class has a number of instance variables, something like [code]int x, y, startX, startY, dx, dy; char* ptr;[/code] There …

Member Avatar for raptr_dflo
0
185
Member Avatar for Vusumuzi

What is actually going wrong? I can see a number of issues, but I would like to know what you specifically are trying to fix.

Member Avatar for raptr_dflo
0
265
Member Avatar for Vusumuzi

It has to do with the additional declarations inside the [icode]if[/icode] statements, and the rules for scoping of variables. By re-declaring the variable [icode]newFee[/icode] inside of the [icode]if[/icode] statements (as a different type, at that), you are masking the original declaration of [icode]newFee[/icode] at the beginning of the function. Therefore, …

Member Avatar for raptr_dflo
0
126
Member Avatar for Vusumuzi

[b]EDIT:[/b] Apparently, you posted your corrected version just minutes before I posted this answer. You seem to have the basic idea now, yes. You're on the right track from where you'd been, but you still haven't quite grasped the function syntax. Specifically, you need to remove the semi-colon at the …

Member Avatar for raptr_dflo
0
138
Member Avatar for Vusumuzi

I'm not certain I'm following you, here; you should be able to nest any sort of loop inside of any other loop, and there's no need for an [ICODE]if()[/ICODE] statement. Can you explain just what you're trying to accomplish? I can hazard a few guesses as to what you might …

Member Avatar for Vusumuzi
0
112
Member Avatar for khsoccer

To begin with, you seem to be having trouble understanding the structure of functions such as [ICODE]main()[/ICODE]. In the function implementation, you do not put a semi-colon at the end of the function header - you only do that with function prototypes, which you probably haven't covered yet. Also, you …

Member Avatar for Schol-R-LEA
0
443
Member Avatar for garu525

I agree with Narue's advice, if it is possible - if you don't have a backup of the earlier version, and aren't using version control, it will be much harder to undo the changes. However, I was wondering if your course of study has covered classes yet; given the number …

Member Avatar for garu525
0
168
Member Avatar for Zssffssz

What I gather out of all this is that you want to be able to write a loader for an executable file, correct? If so, then the reference text you want is [i][url=http://www.iecc.com/linker/]Linkers and Loaders[/url][/i] by John Levine. It covers several executable file formats in detail, including the DOS and …

Member Avatar for Zssffssz
0
394
Member Avatar for cse.avinash

Don't you need to link GRUB (or whatever multi-boot loader you're using) into your image as well?

Member Avatar for Schol-R-LEA
0
217
Member Avatar for Hayzam Sherif

You really can't write a boot-loader in C++, at least not entirely; the first stage, at the very least, would have to be in assembly language, and given that most C++ compilers produce only 32-bit code, you'd probably have to set the system into 32-bit protected mode before you could …

Member Avatar for Hayzam Sherif
0
181
Member Avatar for coolbeanbob

The comment here is incorrect, which may shed light on how the loop is failing as well: [code]while (in_stream >> number) //in_stream >> number returns a Boolean value of true if the operation has been successful.[/code] The [ICODE]>>[/ICODE] operators, as a rule, return a reference to an [ICODE]istream[/ICODE] not a …

Member Avatar for raptr_dflo
0
181
Member Avatar for CD1

While I know you're new with this site, it should be mentioned that [url=http://forums.devshed.com/c-programming-42/crc24q-implementation-846352.html]Cross-posting[/url] is frowned upon as it can cause a duplication of effort on the part of the two communities. It's generally considered best not to cross-post at all, but if you feel you would get better results …

Member Avatar for Schol-R-LEA
0
1K

The End.