2,827 Posted Topics
Re: >> It was originally I spotted this in the debugger yesterday and what was happening it was evaluting 3 of a kind last.. which gave it preferrence as a deciding score. So as an easy fix I just did a reverse array traversal of low_weight[ ] to evalute 'yahtzee' last … | |
Re: >> The researcher never actually returned He does in the video link you posted, which I guess is a modern re-make. So am I to understand that in the original version, the researcher never returns and thus the kid never gets the promised second marshmallow? Fifteen minutes is a long … | |
I'm having some problems using PHPMailer sending to gmail. I have plain-text and HTML e-mail contents. Mail is successfully received at an e-mail address in yahoo mail and an e-mail address in gmail. The problem is that the gmail e-mail shows up in plain text(all HTML formatting removed). The Yahoo … | |
Re: [QUOTE=alexchen;]It is impossible. If it is possible it will become useless.[/QUOTE] It's possible. It's not useless. The OP will need to elaborate more on his/her needs. Any output can go anywhere. It can go to the console. It can go to the serial or USB port. It can go to … | |
Re: Use code tags. [noparse] [code] // code here [/code] [/noparse] If you are going to use dynamic memory, use the "new" and "delete" commands. [url]http://www.cplusplus.com/doc/tutorial/dynamic/[/url] | |
Re: When you "release" code and executable files, you should have a README explaining what the dependencies are and you should either include the dependencies in the relase or explain in the README what needs to be obtained in order to use your code/program. for example, if you write a DLL … | |
Re: I compiled and ran it and was surprised it compiled and ran at all. Regardless, I think you're playing with fire memory-wise. I'm not sure what this does or why you can get away with it, but I think it's just luck. There must be some default array size somewhere … | |
Re: >> What is it that i need to do? You need to either write your own isEmpty() function or you need to use one of the functions provided by C++'s stack. There is no isEmpty() function in stack, and even if there was, you would still get the error since … | |
Re: Line 7 - a[] and n are your inputs. How do you do you calculate average, sum, and sum squared on paper? Do it the exact same way here. You need a loop and the loop parameter is going to have something to do with n. Within that loop you're … | |
Re: [LIST=1] [*]Why bother porting it? Go into the Properties and change it so it compiles using C. [*]No clue whether the windows.h and stdafx.h can be ported to C, but the rest of the code can be ported to C++ easily. I see a problem with the struct syntax, but … | |
Re: I don't see any "push_back" statements. The whole idea of a vector is that you don't have to specify any array indexes. If you're going to do that, might as well use an array, not a vector. | |
Re: The thing is I am trying to turn my code from this: [code] *______* **____** ***__*** ******** ***__*** **____** *______* [/code] into this: [code] *________* **______** ***____*** ********** ***_**_*** **__**__** *___**___* ____** ____** ____** ____** ____** [/code] Replacing the underscores with spaces. The side being depended on the entered number … | |
Re: My (quite limited) history with using serial ports is that I've always used them for data, not pin high/pin low. I've used the "Java Comm" package and a similar class with Visual C++ (can't for the life of me remember which, but it was not part of Visual Studio. Someone … | |
Re: I'll throw in some debugging hints rather than analyze the code itself. You need to find out WHERE and HOW these files are considered different. To that end, for each itereation through the loop, display wehn the test PASSES, not just when it fails. It may fail immediately after reading … | |
Re: >> YES opens a complete description of how to use them. The problem is there [B]IS[/B] no complete description/pinned post saying "How to post correctly using code tags" explaining what code tags are, how to use them correctly, why it's important, etc. There has been endless debate on how to … | |
Re: What happened to Narue's old pinned thread on clearing the buffer? It was great. I won't recreate it here. The issue is that >> and get and getline act differently, so when you mix them, you often end up with whitespace remaining in what you thought was a clean buffer. … | |
Re: There's more than one way to do it. Myself, I would set up a boolean array of size 9. Set all elements to true. Now go through the column. Set the array for each element in the column to false. Then do the same for the row. Set the flag … | |
Re: You'll want to take a look at your encrypted file. Seems to me it will end up being a long line of digits with no spaces, tabs, commas, etc. dividing them: [code] 345423562352345423512341234234534253455432454325 [/code] or whatever, representing a bunch of integers. Here's the problem. When you open the file again … | |
Re: There should be a file called libcurl.so and/or a file called libcurl.a in the /usr/lib directory. You need to link one of them. I use the .so file, but I imagine it doesn't matter. Here's a decent tutorial on linking shared objects. [url]http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html[/url] | |
Re: Lines 14 and 15 need types. Line 15 needs an array size. The question is too vague. How to read from the file depends entirely on the makeup of the file. You also need to specify whether you need to write your own << and >> operators. | |
Re: Your setw values in displayStockInfo() don't match your setw values in lines 81 -85, 97 - 101, so I'm not surprised things don't line up. Try using the same numbers? | |
Re: One of your lines of code calls a function that somewhere in the line of stack calls calls a function that has requirements for valid parameters passed to it and uses an "assert" function to validate those parameters. In your case a parameter flunked the test and the program aborted. … | |
Re: The indentation is off and therefore hard to read/debug. Here's the program with better indentation on the loops: [code] #include <iostream> using namespace std; void alternatingSquare(unsigned n); void square(unsigned a); void hollowSquare(unsigned a); int main(){ for (unsigned size = 3; size <= 6; ++size) alternatingSquare(size); cout << endl; system("pause"); return … | |
Re: For debugging purposes I would set up a char buffer the size of CharOrderTuple and read the file into it. Then take the strlen of it and see if it is the correct length. If it is, copy it over to CharOrderTuple with memcpy. If it's too short, I'm guessing … | |
Re: >>however I still need to make it convert whole numbers instead of just integers. Ex: 0.22 or 13.587 etc. Whole numbers are integers. 0.22 and 13.587 are decimals. You may need to develop a more complex algorithm mathematically for this. I'm not sure that just using the % operator will … | |
Re: I got over 100. That's as specific as I'm getting. It doesn't tell you how many or which ones you got wrong. | |
Re: [QUOTE=peachslasher;625042]Hi guys, I am trying to write C++ method to return a pointer to the parent of a particular node in binary tree, and for the root that doesn't have a parent should return NULL. Here is my program so far: [CODE]#include <iostream> using namespace std; class Tree { private: … | |
Re: This is what I've been harping on since the major change-over at Daniweb. Java code is now flagged as C++ code instead of plain-old code if you don't specify Java-specific code tags. It automatically assumes the C++ language. It really bugs the hell out of me. I don't know about … | |
Re: >> By the way, there is an error in this code which will not be directly visible except to an experienced programmer. So now you've spotted an error, but won't say what it is? Anyone completing the code has to fix the error too? To say nothing else, I admire … | |
Re: It runs for me and calls the GetNext function three times, as expected. What is your output and does it run to completion? | |
![]() | Re: "Crashing" how? What line number? Lines 21, 27, 33, 39 are indented, yet not part of any if statement. Are they supposed to be? If so, you need some brackets. |
Re: >>After I remove the first item from the array, everything will be affected and the program wont execute. Is this correct? The program should always execute. If it doesn't, there's a bug Arrays are always consecutive. No holes are allowed, so things need to be adjusted. Adjusting involves moving memory … | |
Re: You need to take the struct definition on lines 1 to 28 out of main and stick it above the first function declaration that uses it on line 16. If you change the struct to an array, it might also be easier: [code] struct comboNums { int numbers[5]; }; [/code] … | |
Re: Lines 40 and 46 - These lines won't compile at all with many compilers since dicerolls isn't constant. Where exactly does it crash? What line number and what's the error message? | |
Re: Here's the code you posted. Does it compile? What's the question? You apparently have created the GUI, but I don't see the calculation code. As a design note, I don't know if I would have "car" extend JFrame. Consider naming your JFrame "InterestCalculationGUI" or something. When I see "Car", I … | |
Re: It's a common assignment. How in depth are you getting here? It can be fairly trivial or a huge multi-city, multi-day, multi-airline project. You haven't given us the detail we would need to help too much. As far as tools go, depends on the operating system and again, what you … | |
Re: The devil is in the details. Is there a GUI involved somewhere? What's the operating system? When and whether to use threads versus processes and how and whether to share memory and how one process communicates with another is all on a case-by-case basis. It's hard to offer an opinion … | |
Re: What exactly is the problem? It compiles fine. Right off the bat, though, I ran it without the input file and it doesn't exit, so you need to change it so it checks for a bad stream before attempting to retrieve data. | |
Re: Then you need to have a file in the root directory and use the fstream library to read from it and write to it. When the user clicks one of the buttons or whatever, you'll have a function that is called and figures out what to read/write based on whatever … | |
Re: You tackle it by keeping a tally of the number of times you go through the loop for a given n, then finding a pattern and making a math program from it. So assign n to equal 1 and figure out how many times the cout statement displays. The do … | |
Re: Please repost using code tags. [noparse] [code] // code here [/code] [/noparse] [LIST=1] [*]Use iostream, not iostream.h [*]conio.h is not needed. All it does is complicate things for the rest of us. [*]Ditto clrscr(). It adds nothing to the program, plus we can't compile it. [*]Change "void main" to "int … | |
Re: [code] int songNumber = 1 2 3 4 5 6 7; [/code] This is illegal. Try this: [code] int songNumber[] = {1, 2, 3, 4, 5, 6, 7}; [/code] | |
Re: Here's your code, formatted. [code] #include <iostream> #include <queue> #include <time.h> using namespace std; class Customer { private: int arrivalTime; int serviceTime; public: Customer() { arrivalTime = 0; serviceTime = 0; } Customer(int arrival) { arrivalTime = arrival; serviceTime = rand()%9 + 2; } bool done() { return (serviceTime-- <= … | |
Re: If you are looking for wisdom, inspiration, characters as role models who toil with the big moral issues about how to live life, here's a few... Mississippi Burning A Time To Kill Angels With Dirty Faces State Of Grace The Grey Zone | |
Re: [LIST=1] [*]Why did you write your own strlen function? [*]Should your strlen function return the same value as cstring's strlen function? [*]If so, you need to rewrite strlen because it gives bad results (i.e. "a" will return 2, not 1). [/LIST] | |
Re: >> I have a feeling my logic is off here.....crashes randomly depending on input Seems to me it should crash EVERYWHERE, REGARDLESS of input. Nowhere do you have the following: [code] new double[...] [/code] Yet you fill in the array with doubles. That's a seg fault. There's no memory for … | |
Re: Your program flow is a little off. You want to have an outer loop that you go through once per game and an inner loop that you go through once per guess. You get out of the inner loop by guessing correctly or deciding you don't want to guess anymore. … | |
Re: Lots of different ways to do all of this. Some require using one dimensional arrays, some require using two dimensional arrays, some requiring no arrays at all. I don't know why you'd want a 2-D array here unless you are using C-Style strings. Use C++ style strings and you only … | |
Re: One, mark your old threads dealing with this question solved so people don't waste time commenting on them there instead of here. Two, what's the question? | |
Re: Not sure if you intend this, but you have you open and close your file within your do... while loop. That means that you're going to continuously overwriting it. Beyond that, assuming that the above isn't the problem, as far as debugging, stick some pauses in there after it opens, … |
The End.