1,684 Posted Topics

Member Avatar for desidude

[QUOTE=desidude] the ERROR message is --------------------Configuration: main - Win32 Debug-------------------- Compiling... CComplex.cpp C:\cworkSUMMER\COMPLEX\CComplex.cpp(8) : error C2011: 'CComplex' : 'class' type redefinition[/quote] You gave the class definition already in CComplex.h, which got #included into the file. You don't need to define it again. [QUOTE=desidude]C:\cworkSUMMER\COMPLEX\CComplex.cpp(115) : error C2679: binary '*' : no …

Member Avatar for Rashakil Fol
0
234
Member Avatar for cpp noob

Well how advanced do you want it to be. When somebody types, [code]What is the reason for OO design?[/code] do you want the program to give an opinionated, zealoted reply? Or do you just want to search for "hello", "how are you" and if there's a match reply then?

Member Avatar for winbatch
0
120
Member Avatar for peaceofmind
Member Avatar for peaceofmind
0
209
Member Avatar for Mahen

[QUOTE=winbatch]Also note that it's safer to memset these strings before doing anything with them, ie: char prog[200]; char mir[200]; memset( prog, '\0', sizeof( prog ) ); memset( mir, '\0', sizeof( mir) ); [/QUOTE] This is not safer. It is only helpful when an algorithm is broken or if the algorithm …

Member Avatar for winbatch
0
620
Member Avatar for zerenoa

Telling you the answer would basically be doing the whole assignment for you. You need to think harder. You're using printf?...

Member Avatar for Dave Sinkula
0
165
Member Avatar for Rearden

The [font=monospace]pack.at(0)[/font] behavior is of standard library vectors, not arrays.

Member Avatar for Rashakil Fol
0
263
Member Avatar for jepapel

Why are you so impatient? Make an array of integers of length 256. Maybe named 'nums'. Use the character as the index; to get the number for 'x', you'd write nums['x']. You'll need to initialize the values of the array of course. And pray that your characters are eight bits. …

Member Avatar for zyruz
0
338
Member Avatar for vidya

You need to be more detailed. In general, you can execute executables with backticks. E.g. [code]`dir /p`[/code] There isn't just some "command" in the Perl language that does what you want, though.

Member Avatar for Rashakil Fol
0
436
Member Avatar for k_en

[QUOTE=zyruz]somthing like this: [CODE] #include <iostream> int main () { char c[6] = "45678"; int num[5]; for (int i = 0; i < 5; i++) { char temp = c[i]; num[i] = atoi(&temp); std::cout << num[i] << std::endl; } system("pause"); }[/CODE][/QUOTE] This code is downright dangerous. Suppose I add one …

Member Avatar for Drowzee
0
378
Member Avatar for djbsabkcb

Here's how to understand the problem: Run through your code, step by step, on paper. What did you want to happen? Why is it not happening? Right now, it looks like your program is trying to calculate the value of pi/4. Will [font=monospace]( num_darts != 0 )[/font] evaluate to true …

Member Avatar for djbsabkcb
0
2K
Member Avatar for djbsabkcb
Member Avatar for jhdobbins

Your main problem is program design. If you designed the structure of your programs better (using subroutines, no gotos), your problems with pointers (and everything else) would diminish. The main reason that you can't maintain this program is that you have designed it for unmaintainability.

Member Avatar for jhdobbins
0
247
Member Avatar for Kazastankas

[code]std::vector<std::vector<int[color=red]> >[/color][/code] Kaza, your problem from before might have been that you didn't have a space between these two right angle brackets. You need a space. Without a space, the angle brackets get interpreted as a '>>' operator.

Member Avatar for Kazastankas
0
176
Member Avatar for desidude

Suggestion 1: Put your code in code tags. Why are you [font=monospace]break[/font]ing when the remainder is 1? I think you want [font=monospace]rem = divisor % 16[/font] to appear before [font=monospace]divisor = divisor / 16[/font]. Your while condition should be: [font=monospace]while (divisor != 0)[/font] Also, you forgot the cases where your …

Member Avatar for Kazastankas
0
265
Member Avatar for paladin4service

From what I've read on Wikipedia, it looks like you want the magnitude and the argument of a complex number. Suppose the real part is stored in [font=monospace]re[/font] and the imaginary part is stored in [font=monospace]im[/font] (both doubles, presumably). Then [code] double amplitude = sqrt( re * re + im …

Member Avatar for paladin4service
0
1K
Member Avatar for tundeakins

Will I receive college credit for doing this work? How about you do it yourself and then come here when you have problems.

Member Avatar for Narue
0
162
Member Avatar for jennrenn2003
Member Avatar for jennrenn2003
0
78
Member Avatar for michael123

Use GET for a location if you want somebody to be able to revisit the page. For example, search engines use GET.

Member Avatar for Electrohead
0
181
Member Avatar for desidude

The average is 76.4666. desidude, since your sum and count are modified after the while loop, only the last value of your numbers gets added to sum, and count gets incremented once, from zero to one. And 77 is your last value.

Member Avatar for desidude
0
225
Member Avatar for logic321

Your [font=monospace]main[/font] function is ended with a closing brace before your array line.

Member Avatar for Narue
0
393
Member Avatar for Kob0724

You have a semicolon in the line [code]while (iexit == 1);[/code] This is equivalent to the following: [code]while (iexit == 1) {}[/code] So you have an infinite loop that does nothing.

Member Avatar for Narue
0
179
Member Avatar for dark7angelx07

In the more general case, you could look at this problem as popping one stack and pushing another stack. (The stacks containing decimal digits.): [CODE]#include <string>[/CODE] [CODE]std::string rev_digits(unsigned long n) { std::string ret; while (n) { ret.push_back('0' + (n % 10)); n /= 10; } return ret; }[/CODE] or if …

Member Avatar for Narue
1
650
Member Avatar for JoBe

[quote][code]if (name[i] != 0 name[j])[/code][/quote] Is this right? I might write it like this: [code]#include <iostream> #include <string> using namespace std; bool are_mirrored(const string &name, const string &name2); int main() { string name = "Johan", name2 = "nahoJ"; bool c = are_mirrored(name, name2); if (c) { cout << "True!" << …

Member Avatar for Dave Sinkula
0
249
Member Avatar for smartintelleng
Member Avatar for cherryluscious

I recommend starting by giving yourself input and calculating the results by hand. Ask yourself, "What steps am I doing to solve this problem?" Then write down on paper exactly what one does to solve the problem. If you can describe the problem completely, then writing your computer program is …

Member Avatar for Narue
0
158
Member Avatar for shakoush2001

You'll have to use the former method -- C++ programs don't know anything about their variable's names at run time.

Member Avatar for Rashakil Fol
0
171
Member Avatar for JoBe

That's because hulp is just a pointer to a character. Or possibly a character in an array of characters. Not some kind of magical string object. Since you haven't created an array of characters for hulp to point to, when you copy to whatever hulp is pointing to, you're writing …

Member Avatar for JoBe
0
370
Member Avatar for jakejacobson

[QUOTE=jakejacobson]Sorry for not being "smart" enough for you. I am only in my third week of C++. I have no experience in this language so everything is new.[/QUOTE] If this is C++ (right now it's looking like C code with cin and cout statements) I recommend using the standard library …

Member Avatar for Rashakil Fol
0
337
Member Avatar for mina1984

[QUOTE=murschech]The response from shre86 is just the euclidian algorithm for the gcd. I can't resist showing you the recursive way to do that. [code] int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a%b); } [/code][/QUOTE] I edited my quote of your code to fix …

Member Avatar for mina1984
0
392
Member Avatar for mina1984

Okay. Generally speaking, tail recursion (where the last thing to be executed is the recursive call) can be optimized to some kind of loop. Not necessarily a "for" loop. Here's a step by step process for doing it. We'll use the GCD example that lies in another thread. The greatest …

Member Avatar for Rashakil Fol
0
205
Member Avatar for djbsabkcb

You are immediately overwriting the passed parameter in the first line of your get_gas method. Why?

Member Avatar for djbsabkcb
0
169
Member Avatar for cpp noob

[QUOTE=cpp noob][code]if(years1>1999) leapdays1--; //2000 is no leapyear[/code][/QUOTE] 2000 was a leap year.

Member Avatar for cpp noob
0
139
Member Avatar for yaan

[QUOTE=yaan]I've used linked lists before. Does anybody have a resource or url address on how to write a linked stack? I need to create a stack with a menu using int and char variables. Thanks.[/QUOTE] A stack with a 'menu'? What do you mean by 'menu'? Creating a linked stack …

Member Avatar for shre86
0
153
Member Avatar for winbatch

The End.