338 Posted Topics
Re: It seems as if you have a solution in mind, why don't you try to implement it and if you have any trouble, post your code along with the question. (Something like "I expected it to do ___ but it is doing ___") Oh, and when posting c code, please … | |
Re: Well...that last example won't work because classes default to private. If you put a public: in front of the int A it would work. However both of the last examples (directly accessing the member or a reference to the member) are violating the principle of data hiding. Anyone using the … | |
Re: Do you need to return the whole result in a character buffer? Could you return a vector of strings with one string per trade? | |
Re: Ok, comments. Indenting is your friend, feel free to use him consistently. First, why use doubles for the elements of the square. They should all be integer values, right? I don't think I'd use a for(i ... for (j ... to fill the box. I would pre-initialize i and j … | |
Re: Is there any chance an OS Design file is human readable? | |
Re: When posting c code, please use c code tags [noparse][code=c] /* Your code here */ [/code][/noparse] Yes, that's where the total=0 goes. You could simplify the following code by using else: [code=c] if (ave>91) printf("A"); if (ave>=81 && ave<=90) printf("B"); if (ave>=71 && ave<=80) printf("C"); if (ave>=61 && ave<=70) printf("D"); … | |
Re: Are you sure the link to test1.cpp is the right file? It is calling members of Logbook that are not defined in logbook.h and if I understand correctly, both files were given and you're not supposed to change them. | |
Re: It depends more on the specifics of what you're trying to do, but the top options that come to mind are using external programs (like sed or grep) to do the removal or if it is simple enough, you might be able to use [icode]FOR /F[/icode] is your version of … | |
Re: If the compiler is complaining, the code is obviously still not right. Maybe you should define the missing symbols? try [icode]int array_words[10];[/icode] right next to where you declare get_content. (They're both used in the same place.) The declaration for [icode]char str[BUFSIZ][/icode] needs to come before the for loop that copies … | |
Re: Your implementation of find_text would only attempt to iterate to lower elements if the current element had no text. Having text does not preclude having child nodes. I rewrote your find_text as follows and I'm seeing output now: [code=Python] def find_text(element): if element.text: yield element.text for subelement in element: for … | |
Re: My biggest complaint with Notepad++ is that I can't configure it to use tab characters for C / C++ code and spaces for Python. I've been using the 'PyAlaMode' editor that came with one of the librarys I install (I think it comes with wxPython). It doesn't debug, but it … | |
Re: We are not, nor have we ever been a 'here is your completed assignment because you asked for it' source of information. Our basic premise is to help you fill the 'gaps' in your knowledge. We help you to solve your own problems. Post some code for how you think … | |
Re: To help me and you think about it, write down in english what you think the compare function should be doing. It will help me to understand what you intended and whether or not it will accomplish your goal, along with whether or not the function is doing what you … | |
Re: Off the top of my head, I suspect that the fscanf is reading too many or not enough bytes. I recommend that you either treat the whole file as binary or treat the whole file as ASCII. Where you do [ICODE]fprintf(fp, "%d\n", i)[/ICODE] and [ICODE]fscanf(fp, "%d", &i)[/ICODE] you could just … | |
Re: The code was really hard to read... When posting c++ code, please use c++ code tags [noparse][code=c++] // Your code here [/code][/noparse] You have a couple of places where your loops are wrong: [code=c++] // This type is wrong, it will go one too far. for(int j=0; j<=asize; j++) // … | |
Re: On line 2, r is coming from the values in the dictionary, not the keys. So you can't use it as a key on line 8, you can't index a dictionary by the definition. You could either test to see if the answer is a key and if it is, … | |
Re: When posting c++ code, please use c++ code tags [noparse][code=c++] // Your code here [/code][/noparse] Don't try to print answer on the 'please enter in two numbers' lines. | |
Re: In your helper function: [code=c++] ostream& operator<<(ostream &output, const BSTree &other) { output << outputHelper(&output, other.overallRoot); return output; } [/code] It doesn't know what outputHelper is supposed to be. You could attempt to call it with [icode]other.outputHelper(output, other.overallRoot);[/icode] but outputHelper is private (as I suspect overallRoot is). I would tend … | |
Re: Unless your application could write to multiple files at once, I suspect that multiple threads won't be much help. It would be hard to get different threads to write to different parts of the same file where the parts don't even really exist yet. | |
Re: I was able to get the vector to work and support the polymorphism: [code=c++] vector<Account *> accounts; accounts.push_back(new SavingsAccount(25.00, 1.00)); accounts.push_back(new CheckingAccount(80.00, 1.00)); accounts.push_back(new SavingsAccount(200.00, 1.00)); accounts.push_back(new CheckingAccount(400.00, 1.00)); for each (Account * pacct in accounts) { cout << "Original Balance: " << pacct->getBalance() << endl; pacct->credit(5); cout << "New … | |
Re: Making it images makes it harder for people to extract, so fewer people will do it, so there is some benefit. If the goal is to reduce automated screen scraping, they have at least increased the amount of effort required. Your last comment about intellectual property being a thing of … | |
Re: I changed the MessageBox output to a System.Diagnostics.Debug.Print so that it wouldn't wait for me to click anything (possibly still reading in the background). VC# Express claimed it was making a project for .Net 3.5 (I made a console application, but did not output to the console.) This load line … | |
Re: Put some more thought into it and ask a more specific question. How do you envision the program (or function) working? What data will be provided to the program? What data do you expect the program to output? Does the user interact with the program? If so, how? What do … | |
Re: We generally do not provide canned answers to problems. Especially not homework problems. We prefer to help you help yourself. In your case, first think about the problem. Think about the steps you would follow to solve the problem by hand. Use that plan as a basic design for the … | |
Re: Just as a comment to the whole process... You declared [icode]info *resident[max];[/icode] (thats an array of pointers to info) but I don't see where you ever allocated the info instances to put in the array. (I suspect this is the root cause of your 'bugging out') Also, Agni is right, … | |
Re: Note 1: Indenting is your friend, make much better use of him. Note 2: if you're in your main() and you return, your program is done I'm not sure what's up with the two-level menu, where you only handle one case from the first menu and two cases from the … | |
Re: When posting c++ code, please use c++ code tags [noparse][code=c++] // Your code here [/code][/noparse] And actually in my testing, that doesn't exit like you want it to. It keeps looping if the character is [ICODE]>= ' '[/ICODE] OR if the count is [ICODE]<= SIZE[/ICODE]. It will not stop until … | |
Re: The counter and the array were both declared inside the sample code (calcList), they wouldn't be visible outside of it. | |
Re: Please post the entire class definition for Account and for Bank. From [icode]class Account {[/icode] to [icode]};[/icode] and the same for Bank. (For this part, I'm not really interested in member bodies, I just want a feel for what data items the class contains and the methods you have defined.) … | |
Re: @nitu_thakkar That appears to be a sort for the characters in a string, to put the highest character in the string as the first character. @taichou The above sort could be adapted to sort strings in a list. Where do the words come from? How do we know how many … | |
Re: I was going to give you Agni's answer (lucky I saw it when I switched to Advanced). Also, there is no requirement that a class have only one constructor. You could actually declare both (not that you want to in this instance): [code=c++] Account(double newBalance) { currentBalance = newBalance; }; … | |
Re: I was going to recommend that you only load the bitmap once, but I noticed that your code already has a comment about it: [code=c++] //initialize the game... //load bitmaps, meshes, textures, sounds, etc.[/code] And your whole [ICODE]x = rand()..., y = rand()[/ICODE] appears to be all about picking a … | |
Re: Let me ask this a slightly different way to see if it helps you think about it. You have 200 pictures, numbered 0 to 199. (I chose those numbers because that matches the index in almost all collection data types.) I propose your screen has a layout something like this: … | |
Re: Just wondering...Notepad and other editor like applications tend to respond to a normal 'terminate' message with a user query if their file has been modified, but don't terminate until they get an answer. Might this be a part of your problem? | |
Re: And even that looks like something the instructor gave you. With the "do not modify" and "add code here" comments: | |
Re: The only answer I come up with (and I did get the same result in my sample code) is that tabs equate to 8 characters. You start the class at the left margin The init function MUST be indented at least one space, but the actual count is not important, … | |
Re: If you post your code with code tags, the whitespace doesn't go away. When posting c# code, please use c# code tags [noparse][code=c#] // Your code here [/code][/noparse] About the private members and array topic, I don't think I understand what you're asking. You can do things like: [code=c#] Console.WriteLine … | |
Re: I doubt you're supposed to search for the password to look for duplicates. The common case is where you refuse to add a user (name) because it already exists. So a function that took the array and a name to search for that returned where the name was found (or … | |
Re: Did you attempt to walk through what your code does in your head? Here's your code with my comments included: [code=c++] // Assign a to temp char *temp = a; // temp and a both point to the original buffer // Assign a to point to a new buffer n … | |
Re: Yes, your understanding was correct, the function was changing its 'copy' of the pointer and not the actual start address. (Changing the actual start address is probably a bad idea anyway.) Your new trimleft would work as written. A few things to think about: This first might actually slow the … | |
Re: You haven't done enough yourself yet for us to provide constructive help without just doing the work for you. (We don't do that here, we help you fill in the gaps where you lack knowledge, but you have to narrow the gaps.) The assignment recommended constructors and destructors, declare them … | |
Re: Well, if you're not afraid of pointers... [code=c] int bin2dec(char * bin) { int n; int sum = 0; while (*bin) { n = *bin - '0'; if (n < 0 || n > 1) { printf("\nInvalid binary character: '%c'\n", *bin); puts("Binary only uses the digits 0 and 1.\n"); return … | |
Re: I think you're going to have to use all of the 'nature' values and then scale from the nature values to your -1 to 1 grid. If the farthest the planet gets from the sun is 152,000,000 km then you might scale to 160,000,000 km = 1. You could continue … | |
Re: Not much on the effort part there... The algorithm will be something like: [LIST] [*]Start at the head node [*]While there is a next node [*]If the next node is the head node, the list is circular [*]If we got to the end because there was no next node, the … | |
Re: Whether or not the text of the PDF is 'available' is an option for the PDF publisher. I remember several tech documents that were designed intentionally to not allow you to copy the text out of them. It sounds as if your target document might fall into that category. You … | |
![]() | Re: Welllll, you COULD enter CTRL-A to get Monday, CTRL-B for Tuesday... (but I wouldn't recommend it). I like some form of menu in this case, something like: What day of the week is it? (1-Sunday, 2-Monday, 3-Tuesday...) Then you could switch on the character entered and use it to set … |
Re: All of the comments I've found (with my Google search that you should have made) indicate that application level programs under 32-bit windows (aka Win32) cannot directly access the I/O ports. The primary suggestion appears to be that if you really need that level of access to the hardware you … | |
Re: The only place in your code where you attempt to print listMain is from inside sort, if the name passed to sort is 'pile1', right? When do you ever pass the name 'pile1' to sort? (You pass the list that is named pile1 to sort, but it is not equal … | |
Re: Coming from python are we? In C++, the quotes (") and (') are NOT interchangable. The following lines in your code: [code=c++] choose[0] = 'alpha'; choose[1] = 'list'; [/code] Generated the following warning in my compiler: [code] rand.cpp(27) : error C2015: too many characters in constant rand.cpp(27) : error C2593: … | |
Re: So 'list' is an index into the virtual heap, and each entry in the virtual heap is a structure that has an elem (the value at that node) and a next (the index in the virtual heap for the entry with the next higher elem). When there are no entries … |
The End.