• Content count

  • Joined

  • Last visited

Community Reputation

1078 Excellent

About mattd

  • Rank
  1. What platform? If Windows, use Raw Input and get events for each device seperately. See here.
  2. gettext

    If you can settle for version 0.13.1, GNU has prebuilt Win32 packages at: The 'woe32' (har, har..) packages.
  3. Quote:Original post by otreum What mattd kind of makes sense, but i'd like to confirm that I understand it. The way I read that code is it checks to see if the input is not an integer (choice)? Right. It checks to see if a value couldn't be extracted from cin to choice (because it couldn't convert a line containing alphabetical characters to a number). Quote:Then goes through a loop.. Not a loop, just a regular statement block. Quote:..that first clears the input cin.clear() , which also clears those "flags" (could you please explain these? I'm guessing these "flags" basically work like a bunch of check boxes?). clear only clears the flags. You can just think of flags as boolean values - have you read about those yet? Quote:Then the next line getline(cin, string()) I'm not too sure about. I think i've only seen this used once. Could you please explain what this line does in more detail? I had a quick read in my other books at what getline is, and still i'm not sure how it ties into what you've written. You say it "ignores" the line entered. Is this because it gets the line in the input (even if it is just one character) stores it, then when getline reaches the end of the input value, it discards whatever was in input?....or am I just talking gibberish? :S You're not far off. You'd normally use getline like this, to read in a line from a stream: string line; getline(stream, line); // read from stream to line However, we use: getline(stream, string()) "string()" constructs a new string variable, and getline dutifully stores a line from the stream into it. The trick is that the string() value is just an unnamed temporary - so yes, it disappears right after getline is finished. You could just use: string ignored; getline(cin, ignored); if the temporary value thing isn't making sense right now. Quote:But I believe the the only stupid question is the sensible one that is not asked. Too right.
  4. Debugging Hell???

  5. When the user enters a line of text that cin (or any other istream) can't convert to the required type (int), cin (or the other istream) keeps the line of text in its stream buffer, and sets its fail flag bit. You're meant to check whether the extraction (via operator >>) actually succeeded or not, and if not, clear the fail flag, read in and ignore the line entered, and retry. Like this: cout << "Choice: "; if(!(cin >> choice)) // check if extraction failed, it returns a bool { cin.clear(); // reset error flags getline(cin, string()); // ignore the line entered cout << "Please enter a number.\n"; // complain continue; // retry }
  6. Quote:Original post by Zael Quote:Original post by KulSeran Quote: It seems to often die in the middle of the map; Sorry i didn't see that before. You have a recursive function there. If it is dieing in the middle of the map, you probably ran out of stack space due to recursing too deep. Hmm... Maybe, but the program never goes above 1% total memory usage according to top in linux. Anyway to increase stack space for a program? You could test the hypothesis using the ulimit command, namely the -s switch. Quote:Or maybe a better question is: Is there a better way to do what I am trying to accomplish? Rewrite the function in question.
  7. At a guess, you are getting a stack overflow. Linux usually has larger stack sizes than Windows by default.
  8. [C++] What library fill those needs?

    What language? If C++, check out CML.
  9. Is that the only linker error you are getting? Are you linking to DevIL as well as your libgraphics.lib in your application?
  10. Networking in C++

    Quote:Original post by Joesavage1 Basically me and my friends want to make a game, and I thought if we're gonna make it we may aswell do it properly in C++. There's plenty of easier, 'proper' alternatives to C++ nowadays, ya know? Quote:Does anyone know how I can create this Client/Server connection? I looked a bit at winsock and some other thing, but no one really described how I got the header files and how I acctually used the functions or anything, which kinda rules them out as options until I get some idea on how to use them.. Have you checked the Forum FAQ, namely question #1? There's plenty of good information and links for general questions like this there.
  11. Quote:Original post by Wan foldl (+) 0 AKA sum :P
  12. WndProc within a class

    Quote:Original post by Matrinix My question, is this method safe to use? I've read at places that the GWL_USERDATA can get overwritten by other applications (or by code you have not introduced). If other code can do that, it might as well replace your window procedure wholesale with GWL_WNDPROC. In other words, not only it is not worth worrying about, there's nothing you could do to stop it. Quote:Also is this considered a fast way to do it? I want to use this to tie in with user input so I want to minimize the amount of time it takes to process a key or mouse event. Yes. The handler is a simple trampoline function, and will be imperceptible in your application's performance, profiled or not.
  13. Python for me too :) def equi(A): lhs, rhs = 0, sum(A) for i, e in enumerate(A): rhs -= e if lhs == rhs: return i lhs += e return -1