1,177 Posted Topics
Re: I think what you are trying to do is convert a non-string to a string representation, yes? If so, look into std::stringstream. You can simply do: [code] std::stringstream ss; ss << yourThing; std::string >> ss; [/code] Dave | |
I've seen a few posts on here talking about "databases" as if they were just files and using fstream to manipulate the file pointer, etc. I'm familiar with SQL, so it would be nice to simply be able to execute sql command (as can be done from vb.net) such as: … | |
Re: I'd say 'a' is the most important. 'b' is really part of 'a'. 'c' is probably referring to the functions in <algorithm>, which C certainly does not have. 'd' is correct, void pointers and preprocessor directives are nightmares! Dave | |
Re: One thing I see is that you are not checking the bounds of the movement - i.e. [code] void movedown(int x, int y) { x = x; y = y + 1; }; [/code] Should be something like: [code] void movedown(int x, int y) { // x = x; //this … | |
Re: There are a couple of non-exhaustive search ideas here: [url]http://www.experts-exchange.com/Programming/Algorithms/Q_23060580.html[/url] They seem to be based mainly on two facts: 1) the board fills from the bottom, so there should be many solutions involving the top of the board that are not possible and 2) for the rows, if you haven't … | |
Re: I only have an answer to the first question. I ALWAYS reference member variables with [icode]this->[/icode]. I've found that it makes code much much more readable. If you have a long function, reader immediately know that this is a member variable and don't have to spend time looking around to … | |
Re: Why is Bugarr defined in that header? If it is not part of the class (which it is not, it is a global variable), then it should probably not belong in the class's header. | |
Re: Please post 'character.h'. I suspect something like this: [code] void Character::Character(); [/code] when it should be simply: [code] Character::Character(); [/code] Dave | |
Re: Why don't you send us your answer and we'll check it? Dave | |
Re: I think the whole thing should be wrapped in a class called Tree or something. Then Root is simply a member variable and can be accessed no problem from all of its member functions (which should be all of the function you have written). Let us know if you have … | |
Re: jwenting - You are exactly right about employers needing to start from scratch. However, this doesn't seem like any inherent problem, it is just a bad (read "old") educational system! I write (read "whine") about this every once in a while - SNIP Dave | |
Re: In recursion you need a "base case". Here I guess the base case is the first line of the song. So your function should probably be called PrintAllPreviousVerses(int verse) and just call it recursively decrementing 'verse' by 1. This actually doesn't seem like an ideal case to teach recursion, but … | |
Re: 1) Please wrap your code in code tags 2) Use std::string instead of char (you'll have to #include <string>) and everything should turn out much better for you :) Dave | |
Re: This is called "ascii art". You should use a 2D array if the number of rows and columns is fixed. "Pointers" aren't a solution to a problem, but rather one of many tools c++ offers. If you have specific questions let us know. Dave | |
(I posted this in the "Geeks Lounge" but didn't get any responses - maybe there'll be better luck here?) Hi all, I was wondering if anyone one could point me to (if they exist) some places to nominate people for enormous contributions to open source and open source philosophy? There … | |
I'm not convinced it isn't just something wrong with my installation, but has anyone else had this problem? Here is a screenshot of daniweb.com in Google Chrome on Fedora 13: [url]http://rpi.edu/~doriad/Daniweb/chrome.png[/url] And here it is (normal) in firefox: [url]http://rpi.edu/~doriad/Daniweb/firefox.png[/url] Are there any known issues like this? Or can someone else … | |
Re: This probably belongs in the 'C' forum as it is not C++. Dave | |
Re: Did you try a simpler program (still using SDL)? Try to get a < 20 line program where the timer doesn't work. Dave | |
Re: Please try to get the problem to occur not in 350 lines, but instead something manageable like 20 lines. Dave | |
Re: You are not resetting x to number.top after the stack is modified. So what is happening is you are setting x to 28, then in the loop you are modifying the stack but simply outputting 28 over and over! You need to add a [icode]x=number.top()[/icode] between the number.pop() and the … | |
Re: I think you need an asynchronous timer as you will need to continue entering numbers while keeping track of the time. Boost has one: [url]http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/tutorial/tuttimer2.html[/url] | |
Re: You're going to have to try it yourself first! Give it your best shot and let us know if you run into any particular questions. Dave | |
Re: Should this be posted under code snippets or something? There's not really a question is there? Dave | |
Re: Certainly you can pare this down to < 20 lines or so with a main function that will show us the problem. Dave | |
Is there a way to edit a post? I think there used to be, right? I don't see an edit button anymore :( | |
Re: Please provide the shortest compilable example code, sample input, current output, and expected output. Dave | |
Re: Here is the algorithm - it is actually quite short and straight forward: [url]http://en.wikipedia.org/wiki/Breadth-first_search#Algorithm_.28informal.29[/url] | |
Re: What have you tried? Lookup "delimiters". Also, unless I'm mistaken, Turbo c++ and Dev c++ are simple IDEs, not languages, right? Dave | |
Re: Narue is right, but if you do want to use a vector for some reason, std::vector has a find() function that does exactly what you're looking for. Here is the example I have: [code] void TestFind() { std::vector<unsigned int> V(10); for(unsigned int i = 0; i < 10; i++) { … | |
I applied for the "Dinner with Dani" a while ago but haven't heard anything else. I also didn't see any mention of when things would be finalized etc. Is the status "wait patiently"? Or did I miss something? Thanks, Dave | |
Re: Looks like you need to increment gradeCount[0] as you've done for 'A', but gradeCount[1] for 'B' etc, rather than gradeCount[0] each time. Dave | |
Re: I don't understand? It looks like you have working timer code - so just put it wherever you want the timer to happen in the real program, right? Dave | |
Re: What is the error? Why don't you put a statement to check the length in all of the queue addition/removal functions. This should help you track down the problem. Also, why did you post this twice? Dave | |
I'm having a bit of trouble with dynamic_casting. I need to determine at runtime the type of an object. Here is a demo: [code] #include <iostream> #include <string> class PersonClass { public: std::string Name; virtual void test(){}; //it is annoying that this has to be here... }; class LawyerClass : … | |
Re: I don't know about the "Chinese" characters, but it should be reasonably easy to fix the message box program. What I would suggest is making a < 20 line (or as small as possible) program that simply tries to display a message box. That should be easily debug-able by someone … | |
Re: Here is an example of how to use strncpy: [url]http://www.cplusplus.com/reference/clibrary/cstring/strncpy/[/url] I strongly suggest that you try little < 10 line demonstration programs, ensure you know how everything works, and THEN write a 300 line program. It will work out much better for you, I am sure. It will also help … | |
Re: Before you push_back the word, I think you can just test if it is a new line like this: [code] if(word == "\n") continue; [/code] Let me know if that does what you're looking for. Thanks, Dave | |
Re: Should these "one time" posters be deleted to get a true idea of the number of users? Or is the 1M user mark something to brag about :) ? Maybe they can be "deleted" in a way that if they come back wondering where their account went it could be … | |
Re: How is 'it' defined? Please provide compilable code that produces the problem so we can take a look. Dave | |
Re: No one is going to your homework for you! Can someone put a sticky next to the "Read This Before Posting" sticky that explains not to post homework questions like this!? Dave | |
Re: 'm' seems to be expecting to map a string to a map<string,string>, but you are trying to tell it to map a string to a string. "Problem is iterator inner" - can you be a lot more specific? Is there a compiler error? Dave | |
Re: [icode]cin>>float scale;[/icode] is not valid syntax. Try simply [icode]cin>> scale;[/icode] instead. | |
Re: You'll have to show us the values of all of the variables you are outputting. One of them must have a new line character. If you can produce a compilable example that writes the 2 line file, we'd be happy to check it out. Dave | |
Re: Surely you can find (b) on any stl tutorial. I'm sure (a) is there, too. If you provide your draft of an answer, we can verify that it seems reasonable. | |
Re: So you want me.txt to open in notepad and you.exe to execute? | |
Re: This is entirely too generic of a question. Please give it a try and let us know if you have specific questions. If you've already written a game, surely is won't be hard for you! If you're using a library like SDL or something already, they will surely have a … | |
Re: Please use code tags. It significantly improves readability (and hence likelihood of a reply :) ) | |
Re: The function is defined in a namespace: [code] namespace scythe { /*! @cond */ /* Forward declarations */ double gammafn (double); [/code] So you have to call it like this: [code] double k=scythe::gammafn(5.0); [/code] It seems completely crazy to me that they do not include any examples!! Good luck. Dave | |
Re: I think you'd have a lot better luck on the OpenCV forum. Dave |
The End.