Advertisement Jump to content
  • Advertisement

cgoat

Member
  • Content Count

    422
  • Joined

  • Last visited

Community Reputation

132 Neutral

About cgoat

  • Rank
    Member
  1. Quote:Original post by Bregma Speaking from experience, ODBC is the way to go. It's available on Windows (natch, it's originally a Microsoft product), Linux/BSD, and Mac OS X. It's database agnostic (we switched from MySQL to PostgreSQL without recompiling). It's well documented, well tested, supported, and widely used. --smw I'll second ODBC, it's pretty straightforward and you can follow the MSDN documentation on the API calls. unixODBC or iODBC would be your non-windows versions to use (I've always used unixODBC). They're just a manager library though, so you also need a driver specific to your database (like MyODBC for MySQL). Basically you make the call to the ODBC library, which then calls the database specific driver implementation to do what you want. The only thing I don't like is the C style API, there's a lot of repetitive code setting up handles and checking results. I recently started using a library called ODBC++ that wraps it into C++ classes modeled after Java JDBC. It uses exceptions and std::string so it's much cleaner. The documentation for it is pretty sparse though, the only tip I can give is to remember to use std::auto_ptr within the try/catch blocks. I think it's pretty easy to find the class/method that matches the ODBC function you would use in its place.
  2. I didn't mean to imply that the iostreams were better or anything... just a comment on how I hadn't used that particular language feature since starting to use iostreams more often.
  3. cgoat

    Parsing an address...

    Seems like an impossible problem, if commas can't be guaranteed. Looks like the only guaranteed comma is after the name. That means you have no way to tell where the address 1 ends and the next field begins. Since different countries are an option, you can't even guarantee the format of the PostCode. If there's always a comma between fields, then you can probably come up with something (unless fields can contain commas).
  4. I knew about that. I think it's great for breaking apart long lines, to keep the code neat and readable. Don't remember how I first found out about it though. Then again, I haven't really used it since I started using C++ streams, I just do something like this: cout << "I" << " am " << " fine " << endl; In order to break up any long character strings and keep things readable. Fun stuff!
  5. The send/recv calls you have now look correct. You'll want to check the return values of your send/recv call. If that recv is returning an error (-1), then you didn't receive anything, which might explain why it's printing 0 for the value (assuming you initialized it to 0). For example, if you set the socket in a nonblocking mode, your recv calls will return -1, with the error code set to EAGAIN, meaning you should try the receive again because there's currently no data available. The way your code is now, you want it to be in blocking mode, so recv won't return until it actually gets some data, or the connection breaks.
  6. If you want to use pattern rules, also use a VPATH option. VPATH specifies the path where dependency files can be found (the CPP files). In your case, you'd want to do something like: VPATH=Include/Classes:Include/OpenGL Which would allow the generic pattern rule to work like this: %.o: %.cpp $(GCC) $(CPPFLAGS) -c $< Thus, when it gets to OpenGLStart.o, and it can't find OpenGLStart.cpp in the current directory, it'll also check the VPATH for it, and find it there. That will allow you to get rid of the rules for each different .o file.
  7. It doesn't seem that the OP was told "don't use break", so taking off so many points for something he didn't know about that isn't even wrong doesn't seem fair.
  8. Sounds a bit harsh to me, for something that's valid working code and mainly his opinion that it's dangerous. FWIW, I use break in a for loop when I'm doing something like looking for the first item that meets some condition. The for loop is set up to search through the entire array, the break is for when I found what I'm looking for. An accompanying comment is enough so that anyone else realizes there's two ways out. I find it much cleaner than having a bunch of && statements in the loop condition.
  9. cgoat

    Commas in C++ 'test' statements...

    Probably because there's multiple "i" variables. i__1, i__2, i__3. Judging from the code already presented, the coder seems likely to have done that instead of having meaningful names.
  10. According to MSDN library docs, they exist. They're probably in another header somewhere that gets included by the algorithm header. Although my version of MSDN has the following warning in it: Quote:To avoid conflicts with min and max in WINDEF.H, use _MIN and _MAX instead. These macros evaluate to _cpp_min and _cpp_max, respectively.
  11. I believe the following will work: Class definition: std::vector< std::vector< int > > m_vector; Initialization list: m_vector(20, std::vector< int >::vector(30, 0)) That'll give you [20][30] sized, with all values initially set to 0. Edit: Too late, what he ^ said. Mine is wrong anyway.
  12. In general, you really don't need to worry about the precision, unless you're doing some really high precision math where a difference of 2^-16 or so matters. Just remember to format your numbers on output, and never use an == comparison for floats, and you probably won't even notice that the numbers aren't exactly represented behind the scenes. With sprintf, use something like "%6.3f" or "%8.5lf" as the format specifier (find some good documentation on printf format specifiers to understand that better). With cout, use setprecision(), I think.
  13. You're letting the two screens confuse you. They have no impact on the problem at all. It's the same thing as having two windows on the same screen, as far as the program is concerned. Most likely, it's just one program that creates two separate windows. When you do something in either window, it changes some data within the program, then both windows are updated to reflect the current data.
  14. cgoat

    Wingrep?

    I like PowerGrep (www.powergrep.com).
  15. scanf style methods return the number of matches found. So your second statement will return 4 on success, not 1, since you're getting 4 values.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!