2,045 Posted Topics
Re: Make search_num return a bool, it'll make life easier. Be careful with lines like 46, just assign 0 instead. False might work, but it might not, I'm not sure. Look at lines 54-56 for one of the major sources of error. What you have done is declare 3 variables within … | |
Re: Where does j come from on line 66? In terms of what you are trying to do, at which step is it failing? | |
Re: Look into the [icode] .push_back() [/icode] method of the vector as well. Otherwise you are treating your vectors like arrays and they have so much more power than that. | |
Re: [url]http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/[/url] Note that it takes a C-string (so if you're using std::string you need to use the [icode] .c_str() [/icode] method) | |
Re: Can you post this portion of your code? You are probably trying to call a function that is not declared. | |
Re: You need to use the functions in iomanip. The decimals are there, they are just not being displayed. So, [icode]#include <iomanip> [/icode] and see [url]http://www.cplusplus.com/reference/iostream/manipulators/setprecision/[/url] . You'll have to set the fixed setting first like they do in the example. | |
Re: Please post the code that you tried or a subsequent attempt without using switch (as neither one requires it per se). | |
Re: Yes. [url]http://www.cprogramming.com/tutorial/friends.html[/url] | |
Re: AD's got it I think: [url]http://www.daniweb.com/forums/post1395916.html#post1395916[/url] (OP double posted this) The problem is, the order of which the ++ and + will happen is implementation dependent. | |
Re: You want to include <cstring> (which is the old string.h from C that has strcpy, etc) instead of <string>. As you have it now, you are including <string> which has a class named std::string, which is probably causing a name collision. | |
Re: Ask the user for a starting coordinate (row, column), orientation (horizontal or vertical), and size of ship. Make sure the ship will fit in the area (i.e., isn't too long in one dimension or isn't already taken up by another ship). Change the value of the board at the appropriate … | |
Re: Evidently there's a configuration option that needs to be set (see [url]http://davis.lbl.gov/Manuals/GDB/gdb_21.html[/url] at the top of the page) | |
Re: At least make some attempt at the StringModify methods first. Just posting the skeleton provided by your instructor isn't sufficient. | |
Re: I tried a few things, but I didn't come up with a solution. I don't use this date format on my machine so I couldn't test it fully anyway. You could always use the [icode] dateTimePicker1->Value = DateTime(year, month, day); [/icode] overload (where those are ints), but I'm not sure … | |
Re: You never use the i from your for loop in the calculation. You should use that value to calculate the monthlyInterestRate inside of the loop. | |
Re: [icode]for(index = 0; index < score_length; index++);[/icode] Something is amiss on that line. Check the end of it. Doing this causes the for loop to run score_length number of times with ";" as the line to be looped over. You may want to pass the number of elements in the … | |
Re: In the second one, length is a method of the string class, so therefore you call it on s directly, like [icode] s.length() [/icode] | |
Re: Nothing that I can see. What is the result you are expecting? (note that you don't have a newline after your cout, so your numbers are all crammed together. | |
Re: [QUOTE=Ancient Dragon] In the constructor you need to allocate memory for the array [icode]vector = new float[x];[/icode] [/QUOTE] Where have you done this step that AD indicated? | |
Re: And I made jwenting say that with my Jedi powers (forget anything scientific). The test was too obvious the way it was laid out (still my score was just about "e" which gives some logarithmic significance to my answers). | |
Re: Your function does not belong in the middle of main [code] #include <iostream> using namespace std; int SumN(your parameters here); //function prototype int main() { } int SumN(your parameters here) //function definition { } [/code] Note you can put your function definition where you function prototype is and forgo the … | |
Re: [QUOTE=gerard4143]O.K. What do you have so far?[/QUOTE] Agreed. @OP - what system or API are you using to get the mouse coordinates? Win32API? something proprietary? | |
Re: What does the file look like, can you give a sample of a few lines of it? | |
Re: My similar issue had cleared up and has remained clear for months, despite having reported posts in the meantime. I thought you'd updated/cleared the cache on the server(s) to pull it off, Dani (I may be wrong as I know nothing of that fun). You can celebrate both times you … | |
Re: I'm not certain what the exact problem with your program is, but Dev-C++ is no longer in development, so the one that you can download will almost certainly have an older version of Mingw (Windows port of gcc/g++). That should mean that some portions of your program should run more … | |
Re: [icode]main()[/icode] is never void, it always returns an int according to the standard. As to your actual problem, you are mixing up the syntax for printf (the function in the C standard library) with the syntax for cout. Look up the syntax for cout (or find one of countless examples … | |
Re: Get rid of the [icode] 'q' != [/icode] part and test whether str is equal to q before line 21. If it is, break out of the loop. That's probably the most straightforward way to to do it. | |
Re: I can't tell if this is all you are looking for (as you posted a boatload of other stuff) but check out [url]http://www.daniweb.com/forums/post9554.html#post9554[/url] and scroll about 1/4 page down and that will tell you how to get a number within a range. [quote]To be implemented by contestant: player.c or player.cpp … | |
Re: It shouldn't all be crammed into main() like your code example, according to your assignment. Your main() will have your variable declarations and other such housekeeping, but it will be closer to what you put forth in your "Ex". | |
Re: It's s bit confusing, but it seems to be asking you to apply sumN() to each element of your array. This would be a good spot to use a loop over each of the #size inputs. Keep it in main() and model it after your input loop. | |
Re: You can train a dog to paw the keys on a typewriter, that doesn't mean it can write a novel or care what it's doing for that matter. | |
Re: Take a look at something like [url]http://www.sorting-algorithms.com/[/url] to get the gist of the sorting algorithms. Give at least one or two of them a try (with code, we don't provide code, that's your job) and post back. Bubble is probably the most intuitive, so start with that one, swap elements … | |
Re: Hint: if you don't want to use gdb either grab an IDE that supports it (like code::blocks or Eclipse) or do the poor man's debugger and strategically place some cout statements throughout your code (with labels, so you know where you are) to view intermediate values. | |
Re: Regardless of whether or not it is found, your results section is going to output for the current k, so if k=0, you're going to get index 0 from your other arrays. Some p-code: [code] Input the ID For loop (over all the ids) If it exists, note the index … | |
Re: Sort the two arrays in parallel (every move you make on the scores array, make on the names array so they will line up). Go through a sort by hand and translate those steps involved into a set of loops that will do the same thing. A bubble sort will … | |
Re: Take 62 to 73 out of the loop so they won't display for each character you are checking. | |
Re: See if using [icode] this->Hide() [/icode] on line 5 gives you the effect that you want. Your first dialog will still be in memory. Unless your dialog has lots of controls on it, this shouldn't be a problem. I think this has something to do with the fact that the … | |
Re: Ask yourself these questions...How are you getting repeated numbers without a loop? What makes your program run through a second time? Pretend you are the computer executing your program, write out what the values are at each step. | |
Re: Please use code tags: [noparse][code]//code goes here[/code][/noparse] Change dirpath to a [icode] std::wstring [/icode] and in the open operations use [icode] dirpath.c_str()[/icode] instead of dirpath, since you need a C style string (null terminated) in that particular function. Using the c_str() method on the wstring gives you the [icode] const … | |
Re: I'm confused by your use of double on the function prototype (which is ok where it is, but is usually placed before main instead of on line 6) and void in the definition. You seem to be expecting it to return a double (again, not sure why you want to … | |
Re: Please use code tags `[code]//code goes here [/code]` In your `GetString()` function, add a `cin.ignore()` after the cin.get. There's probably a stray '\n' in the stream which gets picked up by the cin call in the `GetNumber()` function. | |
Re: Really you'd remember "to" and then "en" and then "em" and then in a shocking twist you'd remember "M." That and for you, you'd have #include <stdio.h> tattooed on your arm and not remember why. [QUOTE=jephthah;1185382]I don't know why, but every time i see this thread title [I]Memento [/I]comes to … | |
Re: Which compiler and version are you using? | |
Re: Is it similar to this thread's problem? [url]http://www.daniweb.com/forums/post1340978.html#post1340978[/url] I think Dani had to go to the ad vendor, so it might help if you told her which ad it was. | |
Re: In celebration, I'm going to pour myself a tall glass of "who the hell cares." :D | |
Re: You can't return more than one value. Pass in your second variable by reference: [icode] string takerecord(string & surname) { //set surname equal to surname1 and return name1 }[/icode] | |
Re: Please use [noparse][code]//code goes here[/code][/noparse] (code tags) to maintain the formatting of your code when you post it. What are the errors that you are getting? Try to consolidate your code inside your for loop down to just a couple of lines. Hint: [icode] myStudents[counter] == "Andy" [/icode] resolves to … | |
Re: @evstevemd - the OP is working with .NET so an unmanaged library like that would require marshaling between the unmanaged and managed layers @OP - You should be able to use the C# library in your C++/CLI code. The intellisense in 2010 is crappy for C++/CLI but see what happens … | |
Re: Can you post a couple of lines of your data file? Your code resembles C more than C++ (other than the fact that you included iostream). | |
Re: Use the BackgroundImageLayout property [icode] pictureBox1->BackgroundImageLayout = ImageLayout::Stretch; [/icode] (then, once you resize the PB, the image should stretch with it) |
The End.