364 Posted Topics
Re: Also, why are the expressions in your for() loops different between the two Sort() functions? I would think you'd want to iterate over the items in the array the same way, just changing what field you're comparing.... | |
Re: [QUOTE=coolbeanbob;1691174]Isn't a vector a dynamic array?[/QUOTE] Yes and no. A std::vector is a templated container-class which acts similarly to a C-style array, and will dynamically increase the amount of memory it needs without your direct intervention. The other responder probably meant using a pointer and dynamically-allocated memory to be used … | |
Re: I'll take a stab at understanding you: You find the fundamental object-oriented concepts difficult to understand, particularly inheritance (how a derived class automatically inherits members and methods from its parent class, and only new or changed functionality needs to be specified) and exceptions (a way of propagating error conditions back … | |
Re: Welcome ThePolid, Unfortunately it's hard to tell what might be wrong with your program, since we don't know what your intention is. What is your program [b]supposed[/b] to do? There's an appalling lack of documentation and intelligently-named variables. Please don't make us do this much work just to get started! … | |
Re: You don't need NTFS-specific library, there are higher-level FS-agnostic APIs to get the minimal information you need. I did a quick search for "recurse through directory" on [url]http://msdn.microsoft.com/[/url] and found [URL="http://social.msdn.microsoft.com/Forums/en-US/windowscompatibility/thread/05d14368-25dd-41c8-bdba-5590bf762a68/"]this discussion[/URL], which includes enough source-code to get you started. | |
Re: A couple ideas: 1) Your swapping code in lines 6-9 is broken. Watch the order of those lines. 2) If your swapping was correct, your inner loop would execute either once or not at all, so it should just be an if() statement 3) Once you've found two values to … | |
Re: Let's start at the beginning. 1.) At line 14, you declare a two-dimensional array of int-pointers using uninitialized values of row and col, so who knows how big your matrix actually is. 2.) You then input a value for row, and assign col to be the same value, in lines … | |
Re: Or simply call [ICODE]print2(h, h);[/ICODE] from print(), so that you don't skip the first node.... | |
Re: Let's start with your data structure: so far you have a single array of characters; I think you need at least an array of strings. In fact, to store girls' names and boys' names, you probably want [b]two[/b] arrays of strings, one called girls_names and one called boys_names. You should … | |
Re: Think about what it means "if characters in GIVENWORD can form words in DICTIONARY array". Break that down into smaller steps. Options include 1) Make every possible sub-word from GIVENWORD, and then see if that sub-word is in the dictionary. 2) For every word in the dictionary, see if you … | |
Re: Does it work if you replace [ICODE]outFile.open("out.data");[/ICODE] with [ICODE]outFile = cout;[/ICODE]? With this change you should at least see output to your terminal or IDE output-window. If you have a problem opening "out.data", your error-statement at line 11 will fail. You can't output an error message to a stream that … | |
Re: For your own sanity (and that of others reading it), please indent your code, e.g.: [CODE] void functionName (type1 arg1, ...) { some statements; while (condition) { more statements; } } [/CODE] Also, when your problem is simply that your code isn't opening the specified file, don't post 200 extra … | |
Re: And you still have a local variable [ICODE]int size;[/ICODE] declared near the top of your main(), which masks the global constant [ICODE]const int size = 1000;[/ICODE]. Get rid of the one inside main(), it's not needed and it's causing problems. | |
Re: Near the top of your main(): [CODE] if(inFile.fail() || outFile.fail()) { outFile << "Input or Output file ERROR!" << endl; } [/CODE] but if outFile is in a fail-state, you probably can't output to it! Try instead: [CODE] cerr << "Input or Output file ERROR!" << endl; [/CODE] This will … | |
Re: I don't know how big a manualSetPosition object is, but I wonder do you really need, what, 1.5 million of them? I was about to say I can make an image with 1920 x 1280 "pixels" with no trouble. But then I tried, and sure enough, it looks like I … | |
Re: Excellent. So what's next? (and welcome to DaniWeb!) | |
Re: For one thing, if printSentence() and fprintSentence() are identical except for whether you pass in and use an ofstream&, or just use cout ... then why not just do: [CODE] void printSentence(vector<Clause> clauseArr) { fprintSentence(cout, clauseArr); } [/CODE] Then, is it obvious to you that your first incorrect output line … ![]() | |
Re: I'll take a stab at this, but others please correct me if I'm confused. There are two potential paths to take when -creating- a library ... static vs. dynamic. If you create a "static library", you end up with a large .lib file which contains all the compiled code for … | |
Re: You are correct, you have a logic error (more than one) in your while() loop from lines 25-29. How do you start the loop if you haven't yet read a score? Once you -do- read a score, what happens if it's -1? | |
Re: I'm running Windows7 here, so the details might look a little different on your computer, but you should be able to get to the Add/Remove Programs dialog, and remove VS2010 from there, and it should correctly remove only what it installed that isn't also needed by something else (e.g. your … | |
Re: Instead of reading the entire line into one string, try reading the individual fields into strings (and for now assuming that your input will always have exactly three space-separated fields per line). I'm also going to assume you've covered basic structures, so that you can sort more efficiently: [CODE] struct … | |
Re: Also, are you supposed to be using the STL stack implementation, or is the purpose of your assignment to create your -own- stack implementation? If the former, no problem, you may just need to manually clear your temp stack. How would you go about getting rid of each value on … | |
Re: A worst-case situation for buildHeap (having your array pre-filled with values and having to shuffle those values to create a minHeap) is one in which the first value is greater than at least one of the next two, so that a swap is needed there, and then after that, the … | |
Re: Your code at line 3 is valid because the + operators associate left to right. The first thing it computes is, effectively [ICODE]const string tmpString1 = "*" + greet_space;[/ICODE] which is valid because only the first argument is a string-literal. Then it does [ICODE]const string tmpString2 = tmpString1 + greeting;[/ICODE] … | |
Re: You were doing well with the code you originally posted in the other thread. Or was that somebody else's code you posted? Anyway, your loop for displaying the contents looks fine. The conditional expression for your for() loop (the expression in the middle) is equivalent to [ICODE]clist->ptr != NULL[/ICODE], other … | |
Re: You're re-using variable t as an int counter (in your loops) and as a temporary placeholder during your swap (intending it to be a double at that point). It may not affect your answers, but try using variables longer than one-letter, and making sure that each only has one purpose … | |
Re: You need to read the file in "binary mode". While you can probably do the same thing with fstream, I honestly have never bothered learning how. The C way to do it uses fread() on a FILE* object: [CODE] #include <stdio.h> #include <iostream> using namespace std; ... FILE *fp = … | |
Re: Since you've been told to use pointers rather than array-indexing []-notation, don't think of it so much as "how can i ... put that character back into the string" as "once i've determined the character and replaced the %-sign with it, how do I get rid of the two hex-digits?" … | |
Re: If you're learning about functions, then now is the perfect time to start creating some, right? :) You can put your code fragments all in one program by simply pasting them into the center of: [CODE] #include <iostream> #include <stdlib.h> int main (int argc, char *argv[]) { // program code … | |
Re: Command-line argument handling is certainly a challenge, especially if you want to respond properly to mal-formed entries like "-option=val=somethingextra" or "-option =val" (note the embedded space). To start, assume the user will at least use correct arguments and formatting, so all you need to do is get the name and … | |
Re: Since your main() and your yesno() function appear to do almost exactly the same thing, you probably should spend a little time re-thinking your whole program, as short as it is. If you were to ask me (not that you did), I'd say a function called yesno should [b]only[/b] ask … | |
Re: A probable cause of problems is certainly in your fillParent() routine: [CODE] Node fillParent(Node l1, Node l2){ Node new1; new1.freq = l1.freq + l2.freq; new1.right = &l1; new1.left = &l2; return new1; } [/CODE] You're passing l1 and l2 "by copy", meaning that whichever two nodes you pass into the … | |
Re: Assuming you're running Windows (which isn't necessarily a valid assumption), you're probably interested in the function GetAsyncKeyState() described [URL="http://msdn.microsoft.com/en-us/library/ms646293"]here[/URL]. In general, while it isn't always obvious what function you may need, or how to filter out all the irrelevant chatter, [url]http://msdn.microsoft.com/[/url] seems to be the go-to reference source for all … | |
Re: The most obvious answer is, there isn't a function called "Assembler" in the DLL. Maybe there's a typo in how you built the DLL, or in what symbol-name you're expecting to find in it? | |
Re: From Visual Studio, choose "Clean Solution" from the "Build" menu. This should delete all the intermediate build files and final targets, leaving only the source files. From there, it will -have- to rebuild all the files, so you should be OK after that. | |
Re: This is what we're discussing towards the end of [URL="http://www.daniweb.com/software-development/cpp/threads/390141"]your other thread[/URL]. You need to keep track of how big your array is (how many student-records you [i]could[/i] have) and how much is used (how many student-records you [i]actually[/i] have), and then don't try to look at a student-record that … | |
Re: While compiler error messages are a bit terse, they generally tell you where the compiler found a problem. In this case: [QUOTE] test.cxx:236:24: error: no match for 'operator==' in 'stdRec[mid] == stdIDInput' [/QUOTE] says that the error was found at line 236, and possibly column 24. You need to compare … | |
Re: Take another look at your SearchThis() function -- what does it do to your Head pointer? Probably not what you intended to have happen. Instead use a temporary pointer as you do in addNod(). Also, what happens if the string isn't in the list at all? It doesn't look like … | |
Re: Googling around for glGenVertexArrays got me [URL="http://openglbook.com/glgenvertexarrays-access-violationsegfault-with-glew/"]this[/URL] on the 5th entry, does it help? | |
Re: You need to put [CODE] extern std::ofstream outf; [/CODE] in a header file, and include that header file in any source file that needs access to outf. That just says that outf is of that type, and will actually be allocated -somewhere-. Then in -one- of the source files, you … | |
Re: Just mark the thread as "solved", they don't get deleted except in extraordinary cases. Thanks for trying to clean up though! :) | |
Re: I think you have many problems with your Resize method: [CODE] template<typename T> T Lottery<T>::Resize(T* array, int i) { T* arr3= new T [i]; delete[] array; return array3; } [/CODE] You have (1) dynamically allocated a new array of i objects of type T, and done nothing with it, (2) … | |
Re: [QUOTE=sundip;1682417]I am unable to understand your code [CODE] last_played=new Time (*so.getLastPlayed()); // You are using so as reference(const Song &so) then why you are trying to call with "*" . This call should be so.getLastPlayed() [/CODE][/QUOTE] the .-operator (element-of-object) has a higher precedence than the *-operator (dereference-pointer), so the OP's … | |
Re: Hi BubblesBrian, Programming is a very precise activity. Whether you understand while() loops or not, you will likely find it a frustrating process until you learn to express what you're trying to do clearly and precisely. On the flip side, once you can do that, you'll likely find that the … | |
Re: Looking just at the actual code in sphere.h: [CODE] class sphere { int radius(); public: sphere(); sphere(int InRadius); void(SetRadius(int NewRadius)); int GetRadius(); float CalcCircumference(); float CalcVolume(); }; [/CODE] [ICODE]radius[/ICODE] is presumably your member variable, so it should not be declared as though it's a function. Try [ICODE]int radius;[/ICODE] at line … | |
Re: I'm not sure what you're doing with your [ICODE]words[/ICODE] struct or why you need a vector<> of them. Or why your only reference to the bst, once you declare it, is to insert an empty (by default) string into it, and then print it back out. What exactly is the … | |
Re: Also, don't forget the prototype at the top. Taywin's example would look like: [CODE] /***** Function prototype goes here ******/ double callMyFunc(int v1, double v2); [/CODE] Note that the argument names aren't strictly needed in the prototype, so [ICODE]double callMyFunc(int, double);[/ICODE] is OK, I just find it much more self-documenting … | |
Re: It looks like you're now inputting the flight-path angle from the user after you've read only the first pair of values from the data file. Unless that's what you intended.... Simplify your thinking: the first thing you need to is read all of the data into the arrays. So do … | |
Re: Since you already have menu code written, it's easy to put it into a function that does (most of) that for you: [CODE] // THIS IS NEW CODE (function definition, and open-brace) void printMenu() { // END OF NEW CODE // THIS IS YOUR CODE (indented) cout << "'A' Find … | |
Re: I may be wrong, but I believe "protected" members of a base class are inherited by subclasses, while "private" members are indeed private to the base class, and are -not- inherited (or at least are not accessible) in subclasses. |
The End.