279 Posted Topics
Re: You're trying to pass a const object to a function that does not receive a const object. Change one or the other. | |
Re: You need to initialize filledCount to zero (or get rid of it and just use i). Try putting the [icode]cin.ignore()[/icode] before [icode]cin >> choice[/icode] | |
Re: You're looking for something like this: [code] struct Class { string name; int num; Day meet; // For Day use whatever is appropriate Time start; // Ditto for Time Time end; string teacher; int n umStudents; }; cin >> planner[x].name; cin >> planner[x].num; [/code] As for making the array index … | |
Re: Is it because you're calling [icode]start()[/icode] at the beginning of [icode]getNext()[/icode]? According to your comment for start() it moves the pointer to the beginning of the list. | |
Re: Filter the output with grep: [icode]./Test "$i.txt" "$i.obj" | grep -vi '^[:alpha:]'[/icode] Perl's good for this: [code] for $i (1..5) { for (`./Test $i.txt $i.obj`) { next if /^\s*\w/; print; } } [/code] | |
Re: If the grid is not too large, I would use a 2D array of car pointers as well as the linked list. Init the array to zeroes. When you choose a random position for a car, check that the position in the array is 0, then either store the car … | |
Re: It doesn't always return zero. (Try 4, 5, 6.) But you should probably make at least s a double, and probably also a, b, and c. | |
Re: What is the format of the wave files? Is it PCM or are they compressed? | |
Re: Have you looked at [url=http://msdn.microsoft.com/en-us/library/ms646309(VS.85).aspx]RegisterHotKey[/url] ? | |
Re: That is a contradiction. windows.h provides the functionality of the windows platform. You're probably thinking of some piece of that functionality, such as might be provided by OpenGL etc. | |
Re: I only looked at allocate_memoryi and reallocate_memoryi. Any problems with them probably also exist in the "f" models. Compare the code below with the original carefully to see the differences. [code=c++] GLint ***allocate_memoryi(int nShapes, int nRows, int nCols) { GLint ***shapeArray; shapeArray = (GLint***) malloc(nShapes * sizeof(GLint**)); for(i=0; i<nShapes; ++i) … | |
Re: time's parameter is an alternate return path. If you pass in NULL (or 0) it is ignored. Otherwise, you must pass the address of a time_t object which will be filled with the time. | |
Re: You're gonna kick yourself! Instead of this [icode]for(i = 1; text_tokenized[i] != NULL; i++)[/icode] You mean this: [icode]for(i = 1; i < words; i++) {[/icode] | |
Re: Assuming Windows, here's an example of waiting for an exe to finish. [code] STARTUPINFO si = {sizeof (STARTUPINFO)}; PROCESS_INFORMATION pi; CreateProcess( "\\windows\\notepad.exe", NULL, 0, 0, 0, 0, 0, 0, &si, &pi ); WaitForSingleObject( pi.hProcess, INFINITE ); [/code] | |
Re: I was thinking she needed something more complicated too, but now that I look again, maybe she [i]is[/i] looking for an n-ary tree. Taking her example, starting with a given root word (e.g. "cat"), generate all words with one letter different: [code] * for each letter in word * go … | |
Re: The design depends on how it will be used. Write a driver (a main) that uses the object's interface AS IF it was already written. Then create a class for an object that fits that interface. It also depends on how much detail you want in the simulation. If you … | |
Re: It would seem that your only hope (besides the static idea) is to investigage what MOUSEHOOKSTRUCT's dwExtraInfo member holds. | |
Re: I could be wrong ;), but I don't think it's possible. I believe you have to explicitly give the return type, like so: [code] template <typename U, typename T> U foo(T& param) { return *param; } // ... int n = foo<int>(i); [/code] | |
Re: n and x need to be floats (or better yet make everything doubles). | |
Re: I'm not sure I understand your question. Why can't you just [icode]#include "Point.h"[/icode]? I do not see anything circular here. | |
Re: You need to set y to 1 at the top of the loop so it's initialized every iteration. Your do{}while() condition should be x > 0 since you want to multiply every digit together here. The outer while() condition should still be x > 9. | |
Re: AD: If the (originally) larger number is even you simply don't add the (originally) smaller one to the accumulator. Since "odd" just means that the one's bit is set, it's essentially binary mutiplication using shifts (division by 2) and adds. kuru: Have you written a program before? Do you have … | |
Re: You could try [b]signal()[/b]: [code] #include <stdio.h> #include <signal.h> void cleanup(int unused) { printf("Cleaning up\n"); exit(-1); } int main() { signal(SIGINT, cleanup); for (;;) /* Ctrl-C to exit */ ; } [/code] | |
| |
Re: If you simply want the numbers 1 to 9 uniquely randomized in a row, you could load the row with the numbers 1 to 9 and then shuffle it. No need to pick random numbers and check if they've already been picked. That's always something to avoid, if possible. However, … | |
Re: Your program makes very little sense. Either you are using an object or you are not. You should clarify that with your instructor. This does not look like a case where you would use an object (although I'm learning that school exercises can be weird). | |
Re: Your tobase10 function does not work properly, and it is overly complicated. You do not need log10 or pow. You can loop until result becomes 0 (instead of using log10). A special case here is when result starts out as zero. Instead of pow you can start a number at … | |
Re: People generally like a more specific question. What exactly is the problem? | |
Re: Your example is not quite correct. You mean to do this: [code] base* pb = &d; cout << pb->get_tag() << endl; [/code] Simply declaring a base object and calling a method on it will never invoke a method of a derived object since the base object knows nothing about the … | |
Re: To be complete, there is one other possibility. You can specifically call the non-unicode function by appending A to the function name. The other methods are probably better, though. [icode]ShellExecuteA(...);[/icode] | |
Re: Your gcd is not quite right. The recursive call should be [icode]gcd(x, i % x)[/icode]. | |
Re: > the 15 on line 12 doesn't count either. There are two 15's on line 12. You should probably post this in the Perl section. I'd try (in Perl): [icode]/\..*\s(15|53|92)\s.*=>/[/icode] | |
Re: It's ridiculous. And why do you include list (and the deprecated list at that)? You need to include iostream. And your main signature is wrong. Presumably you're supposed to be reading the input on stdin. | |
Re: And you should use iostream, not iostream.h. [code] #include <iostream> using namespace std; [/code] | |
Re: You need to use [url=http://www.daniweb.com/forums/misc-explaincode.html]code tags[/url], give more details about your problem, and ask a more specific question. | |
Re: I'm not sure what the keyword "class" is doing in your map declaration, but using "int" would work like this: [code] #include <iostream> #include <string> #include <map> using namespace std; typedef map<int, int> t_map_inner; typedef t_map_inner::iterator it_inner; typedef map<string, t_map_inner > t_map_outer; typedef t_map_outer::iterator it_outer; int main() { t_map_outer m; … | |
Re: How tedious it is depends on how many different types you need to reverse. If just ints: [code] typedef unsigned char uchar; union IntBytes { int i; uchar b[sizeof(int)]; }; WriteInt( int n, FILE* fout ) { union IntBytes uBytes; int i; uBytes.i = n; for (i = sizeof(int) - … | |
Re: Your declarations should be more like this. Change the definitions to match. [code] char getStuNames(char [][21], int); double getStuGrades(char [][21], double [][4], int, int); void displayGrade(char [][21], double [][4], int, int); [/code] | |
Re: sizeof p gives the size of an int**. sizeof *p gives the size of an int*. sizeof **p gives the size of an int. sizeof *p[n] also gives the size of an int. | |
Re: You can only put types in the angle brackets. You're trying to use a variable. Try this: [icode]map <int, list<CommandOp> > m_DynamicListMap;[/icode] | |
Re: You should use a const_iterator: [icode]vector<double>::const_iterator pos;[/icode] I'm assuming you have a [icode]using namespace std;[/icode] in your actual code. (Please post runnable code.) | |
Re: You need to instantiate the OutputObject template: [icode]for_each (V.begin(), V.end(), OutputObject<T>);[/icode] | |
Re: That's a lot of code with very little explanation of the problem. Also, too many tabs and blank lines, IMHO. | |
Re: Your basic problem is that you are assuming row is a char when it is actually an int. Additionally, you are using the parameters row and col of the player functions like local variables. Remove them from the function declaration and declare them as locals, making row a char. Don't … | |
Re: USE CODE TAGS!!! Having said that, is it possible you mean to use brk and not sbrk? | |
Re: (Assuming you're not allowed to use std::list...) It can be tricky swapping elements in a singly-liked list. Make diagrams so you can see what's needed. You'll probably need extra pointers to remember the previous elements of the two pointers with which you're traversing the list. Also, after you swap two … | |
Re: People don't generally like "help me" or other generalized titles. A better title for your post would be "Problem in text-based RPG". That sounds much more intriguing! I haven't seen this kind of thing before: [icode]if (Energy >= 5, Energy -= 5)[/icode] Do you realize that the [icode]Energy -= 5[/icode] … | |
Re: You need to declare showBoard like this: [icode]void showBoard(char[][3], int, int);[/icode] Note that this hardcodes the size of the second dimension, but that will be okay if the board is always 3 by 3 (or indeed anything by 3). | |
Re: In C, the assignment operator returns an rvalue. In C++ it returns an lvalue, so your first example should work. (Look up lvalue, rvalue if you don't know what they are.) |
The End.