364 Posted Topics
Re: Instead of writing out to your output file every time you do something, try separating your logic into: 1) read the input file into your array 2) loop over user input, adding students to the array, removing students from the array, or editing students already in the array 3) when … | |
Re: You are [b]providing the filename[/b] via the command-line. You can open the file wherever you like, e.g. by passing the filename to a method. As far as why it doesn't work, you say you can't read in the first character of the file, but there's nothing in the edited-down source … | |
Re: While WaltP's input is excellent, the actual problem with your playerPick is the absense of braces around the code-block for each choice. Starting at line 53, this should be: [CODE] ... if (playerPick == 1) { // indent here! ... [/CODE] and there should be a matching close-brace after line … | |
Re: Since it appears that your Grid2D is a template class that you then specify by telling it what to use internally, it should be sufficient to declare the actual struct-type you need for each specific grid: [CODE] struct fluidProperties1 { float foo; float bar; }; struct fluidProperties2 { float foo; … | |
Re: So what should the find() method be operating on? So far, GreyWolf has written the only code here, other than your definition of your struct. Where's -your- code? | |
Re: If c is not the largest, simply swap it with another element. The following should be sufficient: [CODE] // input values a, b, c here if (a > c) { // a is bigger, so use it for c swap(a, c); } if (b > c) { // either way … | |
Re: After it prints the permutation, it decrements level, returns the k'th element of Value to 0, and returns from this call of visit() to where it was called from -- in this case back to line 23 of the previous call to visit() and it continues with the for-loop. This … | |
Re: If I'm not mis-reading your write-up, the data in the file will all be read into your second array, each element in the array will correspond to one of the gates in the circuit, will have 1 or more inputs and 1 output. (For simulation purposes, you might want to … | |
Re: I thought this looked familiar, then when I went and looked it was [URL="http://www.daniweb.com/software-development/cpp/threads/381429"]your thread.[/URL] You're not using seekg() correctly. The second parameter is the seek-direction (position really, ios::end in this case), while the first is an offset from that position (in your case 0, or possibly -1, see what … | |
Re: You also appear to have an un-matched close-brace near the end of line 878 (I think you meant to provide an open-brace at the beginning of line 877). | |
Re: Also, if you haven't discovered it yet, your conversion is broken starting at line 20. Take any starting number, say, 2937, and trace through that block of code by hand, and see what values it's going to get for the four index variables. | |
Re: Try putting the numbers 1-20 into your array first (in order), and then shuffling it. (Hint: start by picking a random element-index and swapping that element with the last element in the array, now you have only 19 more elements to deal with, etc.) | |
Re: I think the problem is that you've declared it as a member function. Make sure the function is written as Mike said, e.g. [CODE] Element operator + (int a, const Element& b) // note: not "Element::operator +" { Element return_val; // make return_val be the sum of a and b … | |
Re: I'm sure there are plenty of educated opinions on how to perform arbitrary type-conversions. Mine is: exceptions and exception-handling are important where you have insufficient control over determining whether an operation will succeed, but using the tried-and-true method of returning a success/failure indication is preferred, simply because it is more … | |
Re: [QUOTE=ananyadiwas;1643661][cout<<] and [cin>>] are keywords since they are built by characters & have special meaning (i.e, these words are reserved for printing and accepting) in the headerfile [iostream][/QUOTE] All keywords and identifiers are "built by characters", so I'm not sure what distinction you're trying to make here. cout<< is neither … | |
Re: No idea, especially since the line-numbering in the code you provided doesn't correspond to the line-number in the error messages. Perhaps replacing the '.' with another '::' would work? [CODE] _FtpWebRequest->Method = System::Net::WebRequestMethods::Ftp::UploadFile; [/CODE] | |
Re: Ashok1514, You may have missed earlier comments to the effect that this forum is not about providing complete solutions. It is up to the original poster to try to learn from help offered, and write his/her [b]own[/b] code. That said, when posting code in the forum, please use [ CODE … | |
Re: Perhaps the author's intent is: the complexity of [b]finding[/b] the node to delete is O(n/m) (on average), but once found, the complexity of [b]deleting[/b] that node is O(1)? Since I don't own a copy of the book, and you didn't explicitly quote the author, I can't be sure. There is … | |
Re: You're replacing your orig[] values as you iterate across your row. You need two loops here, one which computes your next[] values without corrupting your orig[] values, and then another which copies the all of the next[] values back to orig[]. Once you have your code working, you can have … | |
Re: While system() commands can be convenient to write, they are quite inefficient (your program is running under one shell, and each system() first spawns a new shell, then runs the specified command in that shell), and their use is generally considered poor programming practice. Instead, consider using the [URL="http://www.cplusplus.com/reference/clibrary/cstdio/rename/"]rename()[/URL] function … | |
Re: I just googled "C++ ODBC example" and the first hit seems to be sufficiently useful. You will likely have to adjust various constants in the code, particularly the query and result handling in lines 55-69, and reformat it to match your own coding style (preferably without the goto's), but I'm … | |
Re: At line 11 of your functions code, in Write_maps(), your cast-to-integer doesn't do anything. The expression is equivalent to [ICODE](int(Time))/TIMESTEPS[/ICODE], and Time is already an integer. TIMESTEPS is presumably also an integer, but you apparently have it defined globally (if you can access it in Write_maps()) and also locally in … | |
Re: Your .move() and .show() look ok to me. Have you verified that x and y aren't changing (using getX() and getY())? Have you verified that dx and dy are indeed non-zero for each bullet? Also, do you remember to call SDL_Flip() (or whatever it's actually called, I don't have an … | |
Re: You are correct that you don't want the height, weight and getter/setter methods for them to be static members of your class, or you can't have multiple instances with different values. So you need to fix that first, and then deal with where your Person-instances will live. First of all, … | |
Re: Whether your program uses loops has nothing to do with whether it handles non-ASCII input. I found this at [URL="http://www.cplusplus.com/reference/iostream/"]cplusplus.com[/URL] [QUOTE]As part of the iostream library, the header file <iostream> declares certain objects that are used to perform input and output operations on the standard input and output. They are … | |
Re: [QUOTE=aero31aero;1643253]Actually, I have an assignment from school in which i have to simulate the functioning of a dialog box in dos.[/QUOTE] What does this assignment have to do with capturing screen-display into a file? Your program knows what it displayed on the screen previously, just re-display that when you're finished … | |
Re: Hey Vusuzumi, I'm just catching up with this topic, and I think you've started at least three threads for the same program and basic flow questions (about handling your gender-validation issue). If any are now resolved, please mark those threads "solved". And in the future, please follow up with your … | |
Re: Hi Vusumuzi, What do you mean by "discounts look screwy"? What inputs are you sending into the function, and what result are you getting back? The "random numbers" look to me like they represent "number of students" (10) and "number of sports activities" and "number of other activities" for each … | |
Re: Yes, you should use an if-then-else-if structure in your discFee() function. The usage of the function is provided at line 31 above -- that should give you a pretty good idea how the function should be declared: it will take three arguments instead of two. Also, in your calcFee() function, … | |
Re: Also at line 99, what are you returning from top()? And what did you mean to return? Also, you have an assignment instead of equality-test at line 38, but I don't know what the expression is supposed to do. A close-character will never equal its open-character, and any other non-null … | |
Re: Several problems: You declare variables like ROWS, COLS, ALPH and VIG internally to your Table() method, so they are not accessible out side of it. Fix this by making them members of your Vigenere class, and then either: + pass 'alphabet' into your Vigenere::Vigenere() constructor and initialize them there, or … | |
Re: At this point, you're learning the nuances of dealing with an array vs. a std::vector. One benefit (out of several) of using a vector, is that it maintains its own size for you. With the array, as you're discovering, along with the array itself (or pointer to element zero, the … | |
Re: It is a function. It's name is operator<<, and you could in fact call it as, for instance, [ICODE]operator<<(cout, myList);[/ICODE]. But it's name makes it a special kind of function which overloads the "<<" operator, so that you can more naturally specify [ICODE]cout << myList;[/ICODE]. You can overload mathematical operators … | |
Re: As far as cleanliness, I don't know offhand if you need to resize your QBitArray before assigning into it, but since you know it will be the same length as your input codeString, why not start off with: [CODE] QBitArray codeArray(codeString.length()); [/CODE] and skip the resizing completely? Also, the QBitArray … | |
Re: Your problem isn't with your stack code. I copied it and wrote a simple main() that pushed three constant strings onto it, and it behaved as expected. Instead, understand what strtok() is doing: it's internally maintaining a static pointer to the next token in the string, and returning that. Since … | |
Re: Continuing on, yes, no need to call line a "variable" in quotes. It IS a variable, so of course you can treat it like one. So are inFile and outFile. inFile is called an "instance" of class ifstream. outFile is an instance of class ofstream. line is an instance of … | |
Re: A quick Google search uncovered [URL="http://www.mushclient.com/scripts/showfaq.php?faqid=18&productid=6&searchfor="]this[/URL], which suggests which libraries to add to your build. | |
Re: Please use [ CODE ] tags when you include code in your posts (which you should almost always be doing when you ask a new question). Select the code that you've pasted in, then click the very-clearly-marked "[ CODE ]" icon above the editor. Since you haven't told us what … | |
Re: dyboss, thanks for the assignment text, what code have you written so far? | |
Re: So you're trying to write a 'bot which might, for example, automatically click into the fields on a displayed web-page and enter specific text data for you? Anyway as far as your mouse-link, the first note at the top of the page says the function has been superseded, and provides … | |
![]() | Re: I haven't tried whichever GUI SDK you're using, but I'm concerned about the lack of information provided to the Canvas object. How does -it- know which font to use? Does the same tab always display the same way (whether correctly or incorrectly), or will it display one way, and then … ![]() |
Re: Think about what you need to do. At lines 66-72 you look for a square matching the number, and if you find it, you set it to zero. That much is good. You might want to include code to print an error to the user if he entered a number … | |
Re: Each unique solution has 4 possible rotations (original, 90 degrees, 180 degrees, 270 degrees) and for each of those, 3 possible inversion/reflection states (original, reflected left-to-right, reflected top-to-bottom [*]). Once you have one of your solutions (knowing which column the queen is in for each row), how would you come … | |
Re: All other bickering aside ;), it looks like a big part of the problem might be your re-use of variable n at line 19. Each time through the inner loop, you re-assign n based on loop-variable a and the previous value of n. I don't think that's what you meant … | |
Re: I have no idea why this question is in a C++ forum, unless you want to do this programmatically for some reason. For simplicity, I'd recommend using the relatively common 'zip' tools to zip the contents of the "Client" folder into archive "Client.zip" and then rename the file to "Client.any" … | |
Re: Hmmm, while I couldn't reproduce it, I wonder if the problem is the lack of a space between "#include" and "<iostream>" -- it sounds like it's ignoring the # and trying to do something template-like. BTW, which version of gcc are you using? [ICODE]gcc --version[/ICODE]. I have a relatively old … | |
Re: There are binary distributions available for download for both generic and MSVC-specific needs, at [url]http://curl.haxx.se/download.html#Win32[/url], something there should work for you. | |
Re: Your error message indicates that you're not linking your executable against whatever library contains the compiled implementation code for GetEncoderClsid(). Go back to the documentation on MSDN, there's probably something there that tells you what library you need to specify in your Build set-up. | |
Re: "myPM" is returning something to do with DLLFunc2 (at line31), but lines 51 and 76 are assigning DLLFunc (again) instead of DLLFunc2. | |
Re: It looks like you can export the public-key into a BLOB using CryptExportKey() ([url]http://msdn.microsoft.com/en-us/library/aa379931%28v=vs.85%29.aspx[/url]), but then the BLOB is only usable via CryptImportKey(). You can also export/import the public/private key combo. The private key is private, thus there is no way to export it separately. Instead, you're supposed to use … |
The End.