1,684 Posted Topics
Re: [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 … | |
Re: 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? | |
Re: With Python questions, you definitely need to use CODE tags. | |
Re: [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 … | |
Re: Telling you the answer would basically be doing the whole assignment for you. You need to think harder. You're using printf?... | |
Re: The [font=monospace]pack.at(0)[/font] behavior is of standard library vectors, not arrays. | |
Re: 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. … | |
Re: 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. | |
Re: [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 … | |
Re: 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 … | |
Re: You're dividing your interest rate by 100.0 twice. | |
Re: 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. | |
Re: [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. | |
Re: 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 … | |
Re: 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 … | |
Re: Will I receive college credit for doing this work? How about you do it yourself and then come here when you have problems. | |
Re: If you want help, post the entire script, and use CODE tags. | |
Re: Use GET for a location if you want somebody to be able to revisit the page. For example, search engines use GET. ![]() | |
Re: 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. | |
Re: Your [font=monospace]main[/font] function is ended with a closing brace before your array line. | |
Re: 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. | |
Re: 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 … | |
Re: [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!" << … | |
Re: You probably want to pass by reference. | |
Re: 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 … | |
Re: You'll have to use the former method -- C++ programs don't know anything about their variable's names at run time. | |
Re: 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 … | |
Re: [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 … | |
Re: [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 … | |
Re: 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 … | |
Re: You are immediately overwriting the passed parameter in the first line of your get_gas method. Why? | |
Re: [QUOTE=cpp noob][code]if(years1>1999) leapdays1--; //2000 is no leapyear[/code][/QUOTE] 2000 was a leap year. | |
Re: [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 … | |
Re: Maybe what you really want is a different programming language. |
The End.