2,827 Posted Topics
Re: >> my advice, dont use a recursive function where a loop would suffice You wouldn't write these functions recursively in real life, but as a learning exercise for learning recursion, it's a good exercise. I'm wondering if there will be a follow-up exercise where the OP writes them recursively and … | |
Re: A quick look at the preprocessor article on Wikipedia seems to hold the key. [url]http://en.wikipedia.org/wiki/C_preprocessor[/url] Relevant lines... [code] The following are the first four (of eight) phases of translation specified in the C Standard: Trigraph replacement — The preprocessor replaces trigraph sequences with the characters they represent. Line splicing — … | |
Re: Before coding, you need to decide what a "collision" is. Generally a "collision" would be the two objects having the same coordinates at the same time. From a Venn Diagram point of view, if you draw A and B on a piece of paper, A and B collide if they … | |
Re: >> But what topic do i have to look out for How could anyone but you possibly know? Normally the teacher tells you what the exam is on. We don't even know what courses you are taking. I guess you're studying biology, so take note of DNA and cells. But … ![]() | |
Re: Line 13. Is keytab a TYPE or is keytab the name of a variable? You seem to want to use it as both. I imagine you want something like this: [code] keytab keytabs[NKEYS] = {/* initialization */};[/code] | |
Re: >> why am I doing this in an IDE? Perhaps that's the ANSWER rather than the question. Question : Why are you making variables public? Answer : Because IDEs like NetBeans seem to find public variables and they don't find private ones (you know, when you type in the variable … | |
This link's been making the rounds. Somebody decided that to be well-rounded you should have both brains and brawn, so there's a new sport and it's 100% real. You box for 3 minutes, then play chess for 3 minutes, then box for 3 minutes, then play chess for 3 minutes... … | |
Re: >> its an odd number? And the reasoning behind this guess is...? If you can't fill in the dots, withdraw the guess. | |
Re: Advice on how to implement the functions would be counter-productive if you're at the "complete blank" stage. You can't implement anything if you don't know what each function needs to do, which means sticking comments above each function describing what it does, what parameters it needs, and what it returns. … | |
Re: If you can't pause the program, perhaps you can spawn a child process and have THAT sleep. Or a thread. But I doubt the real solution is to sleep. The real problem, I would imagine, is that it subtracts more than once for a collision, so change it so it … | |
Re: Well if you have five numbers to store, might as well make an array and store them in the array. [code] int random_integer[5]; [/code] Now fill in the array. Once you have that, you'll need some way of converting 5 numbers to a string. [code] string toString(int array[], const int … | |
Re: I'm failing to see the point of lines 72 and 73. Perhaps there should be a "this" in there somewhere? That would solve line 73's problem, but not line 72. I'm looking in vain on line 67 for a variable called "bio". | |
Re: Line 27 - Shouldn't you be checking "found" to help decide what you need to return? What should you return if "found" is false? Is that what you are indeed returning? | |
Re: "Crashes" how? What's the output? What's the error message? What's the line number? | |
Re: Point out the changes you've made so we don't have to scan the code. >> the output aborts itself for some reason The process can either run to completion and exit with return code 0 (whether you intended it to or not) or you can get a premature termination due … | |
Re: It does sound inefficient. If I'm typing in the entire text of Huck Finn and my keywords are "Huck" and "Jim" and I'm already on page 200 and I press a key, it doesn't make sense to parse 200 pages of text that I've already parsed (let's see 80 characters … | |
Re: >> I have intiialized No, you have not, unless there's new code. I'm search for something that looks like "key = new char[...]" and not seeing it. | |
Re: [code] for (int column = 0; column < sales[row].length; column++) { sales[row][2] = sales[row][2] + 500.00 ; System.out.print(sales[row][column] + " ") ; } [/code] Let row = 0. I'm seeing sales[0][2] changing multiple times, 4 to be exact. I doubt you're doing that on purpose. | |
Re: Program 1 has a bad compare function. See if you can spot the problem. [code] int AbstractSort:: compare(int x, int y) //compare func { comparisonCount++; return x -x; } [/code] Program 2 doesn't appear to USE its compare function, so whether it's right or wrong is irrelevant. | |
Re: [QUOTE=jackmaverick1;]but then where are people seeing getting these bits of advice from???[/QUOTE] There's no code and there's no advice. Hence Walt P's sarcastic "psychic" comment. Even if someone wanted to help the OP, it would be impossible. The OP is either just screwing around and doesn't even want help or … | |
Re: Never heard of the jpb package or the DrawableFrame class. Did a quick google and found this link. [url]http://knking.com/books/java/jpb/index.html[/url] Is that it? I see it extends Frame. What you describe sounds like it results from a lack of a call to a component's "super" paintComponent method. It's pretty common. Here's … | |
Re: I've seen quite a few forums where you're required to post an "About Me" introduction in the introduction section before you can post anywhere else. It's all one big long thread. One post each, no responses, and your intro is linked to your profile for very quick reference. It's not … | |
Re: The only transdate I see is a static variable in the Transaction class. Note that you haven't specified public, private, protected, so it'll default to whatever the default is, I can't remember, but you can always provide one(private, protected, public). Anyway, it's static, so you have to provide the class: … | |
Re: I would imagine that the pop() function would be one of the last if not THE last function you'd write. You can't write it without writing top() first. getNumElements() would presumably be written first, followed by isEmpty(), isFull(), and push(), followed by top(). When all that's written and works, you … | |
Re: Stick some variable names here. The compiler doesn't care, but anyone reading it trying to decide what parameter goes with what needs to know, particularly for your question. [code] void tempAvg (double [][MaxTimes], int, int); [/code] This doesn't match the above. Which one are we checking? [code] void tempAvg (double … | |
Re: Rule 1 for readability. Pick some good variable names and throw in some comments. Rule 2 for readability. When you ask the user to enter in information, tell them what you want them to do. All I get is a cursor waiting for me to...who knows? Tell me! [code] scanf("%d",&n); … | |
Re: >> "...something in the loop body must cause the expression to become false at some time. One of the things you do not do ever, is write an if statement to change the loop control variable to make the condition false." Not sure who you're quoting, but I don't see … | |
Re: Line 33 looks problematic on the second insert. I see tail being assigned to 0 earlier, but I see nowhere where you assign tail to be anything other than 0, so on line 33 you would be dereferencing a null pointer. Can't do that. Seems to me that on your … | |
Re: This shouldn't compile (and it doesn't for me). x is out of scope on line 9. What is "less than" something else? Is {5,3} less than {3,4}? Or vice-versa? I don't know what the default "less than" is, for one array being "less than" another, but you can't sort unless … | |
Re: [QUOTE=caltech;1527532]Professor said the same thing as you guys, when he ran it it ran as it was supposed to... He thinks it's my filepath? But it's opening the file. Could it be my compiler? What could I do about the filepath? Unless I reference it from the root /User all … | |
Re: 2-D array constructor... [code] table = new int*[size]; for(int i = 0; i < size; i++) { table[i] = new int[size]; } [/code] 2-D destructor... [code] for(int i = 0; i < size; i++) { delete table[i]; } delete table; [/code] Keep in mind that you CANNOT assume that all … | |
Re: >> Thanks guys. I'm actually not gonna flip a coin. I'm going to weigh the pro's and con's between the two. As far as dilemmas go, having to pick between two jobs/internships is a good dilemma to have. Good luck. | |
Re: One, what's the question? Two, what's the point of the loop fro 25 - 28? Just pick one random number number from 0 to 49 and use that as the index. The array declared on line 9 seems pointless. You're reading in 50 Strings from the file and picking one … | |
Re: One, if you are looking for odd numbers only, check whether sIndex is odd first thing. If not, make it odd by adding one to it. Two, to avoid overflow, you should probably test whether sIndex >= eIndex rather than == eIndex. Three, also to avoid overflow and other errors, … | |
Re: >> Another question!!! How do I get this program to print ei when you input e. Apparently I have to figure out how to mess up my program. Before getting too involved, you perhaps should explain what you're doing and why. I can think of a whole bunch of ways … | |
Re: [quote] I am reading in a set of 10 numbers from a file into an array, then printing the array out using recursion, then I have to take the summation of 1-last number in the array (Ex 1-14). The problem is that my function currently sums all of the elements … | |
Re: >> I refer to those threads as an ambush (I really do). I never thought about it in that term, but damn, you're right. It's manipulative and hostile, isn't it? >> You get someone posting code missing a semicolon, you tell them how to fix it, and they're sometimes like … | |
Re: >> Thanks in advance! Don't thank us. We aren't going to do this for you. Read the rules. You have to show you are willing to put in some effort. Only post here when you get stuck. | |
Re: >> At first i though the problem was that t2 and r were both int,but even when i just write "Km = 16/21" it gives me Km = 0. You've hit the nail on the head I think. That's the problem. 16 / 21 is 0. How can it be … | |
Re: Ezzaral mentioned the infinite loop (why bother CHECKING for changes when you know EXACTLY WHEN things change (i.e. when the timer goes off. Display a printout or update the JTextField only when the time CHANGES). The constant checking and printing hogs a lot of resources. That may not have adverse … | |
Re: Consider the source. Your comment was completely on the mark and justified and you got down-voted precisely BECAUSE it was completely on the mark and justified. Upvoted from me as a counterbalance. | |
Re: I'm the compiler. I know what you want me to do if that big long condition is false. But what shall I do if it's true? You need to tell me. That's the error. Side note: Take a look at the xdigit function. It'll save you a lot of Logical … | |
Re: >> but for some reason its not working Define "working". What's it doing that you don't want it to do or vice versa? It looks like it'll keep fine time. You'll get twenty zillion 0's then twenty zillion 1's, then twenty zillion 2's, etc. I imagine you want to have … | |
Re: The compiler can't figure out what you are trying to do (nor can I), so it's throwing up its hands and giving up and throwing an error. You have three options when declaring a variable (there may be more I am thinking of)... [code] std::string hexNumber; std::string hexNumber(/* some expression … | |
Re: >> Computers are at best my third preferred career path. >> as far as I'm concerned programming for hours at a time is one of the things one encounters in hell. You've answered your own question. Why would you pick your third preferred career path instead of your first or … | |
Re: - Teach Java over two semesters second semester specializing in more complex subjects and networking. I'll vote a definite no to the "specializing in more complex subjects and networking" in a second semester high school class. You might consider it in an elite magnet school like Lowell High School in … | |
Re: Ditto Narue and Jon. One million members is a bad thing, not a good thing. As a side, but related note, I just got an e-mail from Dream in Code very similar to what Dani posted. Apparently they got hit by the same Google update. Relevant sections in red. If … | |
Re: >> memory leak? That's what you have to figure out. "Crash" is too vague. Bad memory management generally fall into a few categories... [LIST=1] [*]You run out of memory. That means you keep allocating and never delete memory and eventually can't allocate. [*]Deleting memory where you shouldn't, then trying to … | |
Re: From cplusplus.com [code] // operator new example #include <iostream> #include <new> using namespace std; struct myclass {myclass() {cout <<"myclass constructed\n";}}; int main () { int * p1 = new int; // same as: // int * p1 = (int*) operator new (sizeof(int)); int * p2 = new (nothrow) int; // … | |
Re: If you're looking for a program that's already written that does this, you're probably in the wrong forum. This is the C++ forum. Such a program may exist. Whether it's legal or publicly available for purchase I don't know. If you're looking to WRITE it, that's a different story. |
The End.