145 Posted Topics

Member Avatar for nomarhere

For information on the help you can expect here with homework problems, have a look [URL=http://www.daniweb.com/forums/announcement8-2.html]here[/URL]. If you have a further look through the forums, there was a thread on your exact topic (more precisely, a discussion of how to evaluate that particular summation) a week or so back. However, …

Member Avatar for grumpier
0
86
Member Avatar for CPPRULZ

You are passing arr, an array of length 3 to the function, and returning arr[5]. arr[5] does not exist, as far as your program is concerned. The array does not get resized. In fact, by doing this (accessing the value of something that does not exist) your program is exhibiting …

Member Avatar for vidit_X
0
350
Member Avatar for tatainti55
Re: C++.

When you install Dev-C++, at some point you need to specify a directory where it gets installed. Whenever you (or a batch script you're executing) refers to D:\gcc, you need to change it so it refers to the directory you installed dev-C++. If you did install into d:\gcc, then presumably …

Member Avatar for tatainti55
0
117
Member Avatar for mugun

More specifically, a [u]small[/u] piece of code that actually exhibits the behaviour you consider to be a problem. The code you've given does not appear related to the text in your post in any way.

Member Avatar for ArkM
-1
142
Member Avatar for luisvega

When you append pointers onto a vector of char, the [u]pointer[/u] is copied. You are expecting the data the pointer [u]points at[/u] to be copied. With a vector<char *> you need to explicitly copy the data as well as the pointer. An easier way would be to use a std::vector<std::string> …

Member Avatar for luisvega
0
2K
Member Avatar for mgirl

You have not initialised min, ret, cent, or invalid, which means their starting values are undefined (ie can contain random junk). Then, in your loop, you increment them. You then add the resultant values to compute total ..... Starting with junk values and incrementing yields more junk. Adding junk values …

Member Avatar for grumpier
0
281
Member Avatar for Barvik

Heaps of things wrong with your code. 1) You need to decide if you are working with a 1D or 2D data structure. 2) You need to decide whether your copy constructor does a deep copy (i.e. dynamically allocating rows and columns, and then copying all the values). At the …

Member Avatar for grumpier
0
122
Member Avatar for monkey_king

You're paraphrasing, based on where you [u]think[/u] the problem is, and the end result is that you haven't provided enough information for people to help. You haven't explained what you mean by "non-working". Does the code fail to compile? Or does it compile, but fail to link? Or does it …

Member Avatar for monkey_king
0
188
Member Avatar for cam875

[QUOTE=cam875;701925]i dont understand the memset thing char* binary = new char[ElementAmount]; memset(binary, 0, sizeof(binary));[/QUOTE] That code is a beginner's error, and tends to yield bugs that are hard to track down. The memset() call should, presumably, be "memset(binary, 0, ElementAmount);" to set all bytes in the dynamically allocated array binary …

Member Avatar for cam875
0
61
Member Avatar for nizbit

[QUOTE=Denniz;701773] Normally I would do something like this for dynamic allocation: [Code] Contestant* C = NULL; C = new Contestant; if(C) // test valid allocation { // do whatever you want here // Memory deallocation delete C; C = NULL; } [/Code][/QUOTE] Your approach will not work: operator new does …

Member Avatar for grumpier
0
102
Member Avatar for ohnomis

[QUOTE=Ancient Dragon;700326]I have no idea how your teacher's program works -- you would have to post it. I can only suspect he used one of the huge integer libraries like I previously suggested. Its also possible he used strings instead of integers to avoid the limitations of integers.[/QUOTE] Oh, please! …

Member Avatar for ohnomis
0
534
Member Avatar for volscolts16

RTFM is the rule, google is your friend that makes it easy to follow the rule. Results of searching for LNK2019 yielded [URL=http://msdn.microsoft.com/en-us/library/799kze2z(VS.80).aspx]this[/URL] and of searching for LNK1129 yielded [URL=http://msdn.microsoft.com/en-us/library/z98k84c3(vs.71).aspx]this[/URL] as the [i]first hits[/i]. In short, you have code that is trying to call a function (or multiple functions) you …

Member Avatar for grumpier
0
100
Member Avatar for Repurcussion

Practically, when working with templates, it is necessary to have the template definitions (ie the implementation of template member functions) in the header file. It is not possible (with most compilers) to compile templates separately. The reason is that, when using templates, the compiler needs to see the definition (ie …

Member Avatar for grumpier
0
827
Member Avatar for ambarisha.kn

[QUOTE=ambarisha.kn;699975]But if i make DB, DC as char its not possible to add 1024. then how to add 1024 bytes to that[/QUOTE] You need to make DB, etc [u]pointers to[/u] char. sizeof(char) is 1, by definition in the standard. So if DB is your base address, DB + 1024 is …

Member Avatar for ambarisha.kn
0
138
Member Avatar for vijaysoft1

Try describing to us what [u]you[/u] think the code does, and we'll check if you're right (or how right you are). You'll learn more if you think it through and describe what's happening so others can understand rather than simply getting others to do the work for you.

Member Avatar for jencas
0
116
Member Avatar for DemonGal711

The cause of your problem is almost certainly code executed [u]before[/u] your red lines are reached. My guess - although you haven't shown them - is that the problems really occur in your input() function or, possibly in your createArray() or removeDup() functions. I'd even guess further that - in …

Member Avatar for grumpier
0
115
Member Avatar for godlike111

[QUOTE=ArkM;697975]Because of no total linear memory space concept in platform-independent C++ language.[/QUOTE] That's not true. The memory model in C and C++ is linear. Or, at least, the memory available to a program consists of a series of one or more sequences of contiguous bytes. However, a pointer is not …

Member Avatar for Narue
0
2K
Member Avatar for daviddoria

Your basic problem is that you need to ensure two bits of information come together: the object to be acted on (eg a pointer to that object) and the function to act on it (eg the member function). glutMouseFunc(MouseButton) only passes information about the function to be called. That function …

Member Avatar for kux
0
670
Member Avatar for scru

While tempted to suggest "draw and quarter", the fairest treatment would be forcing them to pay my internet bill. After all, if they consume my bandwidth and quota without my permission, they should pay me for the usage. The fact I pay for an internet connection does not bestow permission …

Member Avatar for bumsfeld
0
182
Member Avatar for eehyf

Well, yeah, you can look at the first character, but that will not distinguish "Adam" from "Anthony". If the first characters are equal, then it's necessary to look at the second .... and then third, and so on - which is exactly what strcmp() does. As a rough rule, in …

Member Avatar for grumpier
0
154
Member Avatar for Sci@phy

[QUOTE=Sci@phy;694893]Thx, I'm going to do that. But just out of curiosity, let's say i write: [CODE] string *ptr = new string; string *alt = ptr; ptr->assign("Happy Day"); cout<<"On alt adress is: "<<*alt<<endl; cout<<"deleting ptr"<<endl; delete ptr; cout<<"ptr adress: "<<ptr<<endl; cout<<"alt points to: "<<*alt<<endl; [/CODE] Now program is terminated as it …

Member Avatar for kux
0
93
Member Avatar for Clockowl

The standards specify that elements of declared arrays are contiguous. N-dimensional arrays are actually arrays of (N-1)-dimensional arrays. So ..... the compiler is required to do what you want (at least, in terms of storage). In terms of mechanism of element access (eg accessing element_in_N_dimensions vs equivalent access of element_in_one_dimension) …

Member Avatar for grumpier
0
90
Member Avatar for l4z3r

Stepping through a MS-DOS based program in an IDE trying to find the source of a bug. Next thing: the computer did a warm boot, but was unable to come up again because it couldn't find a system drive. After restoring from backup (and being very thankful I had a …

Member Avatar for William Hemsworth
0
140
Member Avatar for coveredinflies

[QUOTE=coveredinflies;690909] Both ways compile so as long as this isn't just lucky I will just learn without the & sign as it makes more sense to me (though maybe it shouldn't lol). [/quote] Without the ampersand (&) the function creates and returns a temporary copy of the object it is …

Member Avatar for vijayan121
0
192
Member Avatar for jits_aps90

1) First, represent a polynomial (of the form c_0 + c_1*x + c_2*x^2 + .... c_n*x^n) is represented by an array with elements (c_0, c_1, c_2, c_3, .... c_n). 2) Work out how to multiply two arbitrary polynomials together. ie. given a polynomial A (a_0, a_1, a_2, a_3, .... a_n) …

Member Avatar for jits_aps90
0
98
Member Avatar for nameless987

Talking about using a sledgehammer to crack a nut. No need to use high precision integers at all. (a^b) mod c can be evaluated using a loop, using modulo arithmetic. The basic property you need to know is that (x*y) mod z is equal to ((x mod z)*(y mod z)) …

Member Avatar for iamthwee
0
1K
Member Avatar for AutoC

According the the C++ standard (Section 5.8 para 1 "Shift operators") "The behavior is undefined if the right operand is negative, or greater than or equal to the length in bits of the promoted left operand." In other words, assuming your unsigned type is 32 bits, you are not allowed …

Member Avatar for Duoas
0
114
Member Avatar for nizbit

Not even close. You have declared myclass's length() method as taking one argument, and yourlen() calls it with two arguments. Similarly, yourlen() is declared with no arguments, but when you call it you pass two to it. (I'll ignore the typo of calling a.youlen() rather than a.yourlen()). If you declare …

Member Avatar for Sky Diploma
0
124
Member Avatar for Jawahar prabhu

[QUOTE=Jawahar prabhu;689845]hi i'm new for c++, i tried to work with mouse pointer on my run window but i dont know how to make interrupt to do it. thanks[/QUOTE] Standard C++ does not allow you to work with the mouse (or interrupts). The techniques are operating system and compiler/library dependent …

Member Avatar for grumpier
0
80
Member Avatar for Demonisya

Firstly, your variables a, b, and c are uninitialised: their value before entering the loop could be anything. As to your loop, it doesn't really make sense. You only need two variables. An index, that gets a value of 1 first time through the loop, 2 the second time, 3 …

Member Avatar for Demonisya
0
116
Member Avatar for MelechM

[QUOTE=jencas;688246]- avoids dangerous recursive call of main() [/QUOTE] In C++, recursive call of main is not allowed at all. To answer the original question, if you must be able to execute a program that reads from standard input and writes to standard output, you need to investigate input and output …

Member Avatar for MelechM
0
124
Member Avatar for dmlandrum

It's say the chance of messing up due to inheritance is the least of your problems. Attempting to avoid problems due to X without even a basic understanding of how X works is a recipe for disaster. And trying to design a framework on that basis is asking for trouble. …

Member Avatar for grumpier
0
93
Member Avatar for nuceyneky

Look up the specification of localtime(). My recollection is that systime->tm_year would be the number of years since 1900. 2008-1900, last I checked, yielded a value of 108.

Member Avatar for Aia
0
124
Member Avatar for YaelGD

Three possibilities I can think of offhand. 1) The way you have created the individual objects (which you haven't shown) is inconsistent with the way you're destroying them. 2) Some operation of the Text type is invalid (eg it mangles a pointer to data internally). 3) Some other code is …

Member Avatar for YaelGD
0
138
Member Avatar for Kadence

Dragon's approach will work .... the only other obstacle is the fact that most systems allow a process to have only a small number of files open simultaneously. If you exceed that number, .....

Member Avatar for Kadence
0
820
Member Avatar for mammoth

The double quotes have to be around the full path names, not around the filename. The command string you need to build is probably "del [color="red"]\"[/color]C:\users\robocop\desktop\a b c.txt[color="red"]\"[/color]"

Member Avatar for Salem
0
99
Member Avatar for vvtc

[QUOTE=Ancient Dragon;681922][CODE] void functijon(int **array) { array[0][1] = 123; } [/code] The above is a 2 dimensional array of integers. [/quote] Not really. array is a (misnamed) pointer to a pointer. It is not a 2D array. However, in some circumstances (eg the code example you gave, although I won't …

Member Avatar for grumpier
0
145
Member Avatar for kneiel

A class declaration is anything, essentially, that tells the compiler a name is for a class. For example; [code] class ClassName; [/code] is known as a "forward declaration". A class definition is a type of declaration that provides enough information that a compiler can create instances of the class, compute …

Member Avatar for grumpier
0
446
Member Avatar for kneiel

That's the way it is. The compiler adds a padding byte. The reason is that each element of an array is required to have a distinct address, and the size of an array with n elements is computed as n*sizeof(element). This would not work if sizeof(element) could yield a zero …

Member Avatar for mitrmkar
0
75
Member Avatar for sadaka

[QUOTE=sadaka;392919] My "Makefile" contains this: [code]EngineMain : EngineMain.o Engine.o (tab)gcc -o EngineMain.o Engine.o EngineMain.o : EngineMain.cpp Engine.h (tab)gcc -c -g EngineMain.cpp Engine.o : Engine.cpp Engine.h (tab)gcc -c -g Engine.cpp [/code] [/QUOTE] The rule above for EngineMain will not function as intended. It should probably be; [code] EngineMain : EngineMain.o Engine.o …

Member Avatar for sparty
0
154
Member Avatar for salman1354

On the other hand, Arkm, don't advocate valarray without a particular reason. The original post provided no particular reason to prefer valarray over a vector. The only requirement stated is ability to represent an array of float with length unknown at compile time. Both valarray and vector meet that requirement, …

Member Avatar for grumpier
0
267
Member Avatar for kalodakilla

That code is too big for anyone to bother looking at. Try eliminating code to produce a [u]small but complete[/u] code sample that exhibits your problem. If you get lucky, you will find/fix the problem in the process of producing that small code sample. If not, people will be more …

Member Avatar for kalodakilla
0
115
Member Avatar for eamonaustin

There are a few factors that conspire to make you have less disk available than the labeled disk size. Firstly, marketeers of hard disks conspire to make you think you're getting more than you are, by defining a GB as a million bytes rather than as 1024*1024*1024 (which is how …

Member Avatar for 4th&3wood
0
195
Member Avatar for kneiel

The reason is that Base is a [u]private[/u] base class of Derived. Implicit conversion from "pointer to Derived" to a "pointer to Base" relies on public inheritance. Code using Derived (i.e. your _tmain() function does not have access to private members or bases - that is what "private" means. Your …

Member Avatar for Alex Edwards
0
174
Member Avatar for Duki

[QUOTE=MONODA;675898]i read that a while back and didnt like it; it seems like all the guy is doing is describing himself and saying everyone else isnt a real programmer.[/QUOTE] And you're suggesting that's unusual???? Virtually every programmer I've ever known considers he or she is the only real programmer.

Member Avatar for grumpier
0
106

The End.