|
floWenoL posted:Why don't you just read the lines directly into the 2-d array? It's a requirement to read them into a ragged array. However, once read into a ragged array, it is free game what we do with them. Like I said, this popped up in my head that the easiest way to solve the dillemma would be to: 1) Read the strings in as a ragged array. 2) Convert the ragged array into a two dimensional char array. 3) Use the two dimensional character array with the rest of my program already written for two dimensional character arrays.
|
# ? Sep 9, 2009 06:23 |
|
|
# ? Jun 8, 2024 06:25 |
|
Since they're just regular old null terminated c strings, there is really no reason to have a square 2d array. Can you post an example of where in your code a 2d array is 'easier'?
|
# ? Sep 9, 2009 08:13 |
|
If anyone could help me it would be immensely appreciated. I'm pretty new in playing around with C++ and MySQL databases, but I'm trying to create an application which connects to a locally hosted DB and does basic I/O. However, upon compilation, it gives me the following errors:quote:1>001_10Sep2009.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall sql::SQLException::getSQLState(void)const " (__imp_?getSQLState@SQLException@sql@@QBEPBDXZ) referenced in function __catch$_main$0 The code can be found here: http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html My intuition tells me the compiler simply can't find the function prototypes or the linker is having trouble in a similar vein. Also, I'm using Visual Studio 9.0.
|
# ? Sep 11, 2009 09:10 |
|
iSuck posted:If anyone could help me it would be immensely appreciated. I'm pretty new in playing around with C++ and MySQL databases, but I'm trying to create an application which connects to a locally hosted DB and does basic I/O. However, upon compilation, it gives me the following errors: You most likely need to add the .lib that goes with the .dll you're using to your project. Your code is calling functions in a dll, but the linker needs to have the .lib file to know how to resolve the calls to those functions.
|
# ? Sep 11, 2009 09:36 |
|
beuges posted:You most likely need to add the .lib that goes with the .dll you're using to your project. Your code is calling functions in a dll, but the linker needs to have the .lib file to know how to resolve the calls to those functions.
|
# ? Sep 11, 2009 10:00 |
|
beuges posted:You most likely need to add the .lib that goes with the .dll you're using to your project. Your code is calling functions in a dll, but the linker needs to have the .lib file to know how to resolve the calls to those functions.
|
# ? Sep 11, 2009 13:30 |
|
I'm not a programming beginner, but I've never learned the first thing about parallel programming/threads/coding for multi-core systems/all that stuff, in any language. Given that I use C++ more than any other language, where would be a good place to start?
|
# ? Sep 12, 2009 06:02 |
|
seiken posted:I'm not a programming beginner, but I've never learned the first thing about parallel programming/threads/coding for multi-core systems/all that stuff, in any language. Given that I use C++ more than any other language, where would be a good place to start? The Little Book of Semaphores is very, very good at presenting the problems associated with parallel programming and the tools used to tackle them. It's language agnostic and should show you all the theory. I've done threaded stuff on Windows and I've used the critical section ( essentially a mutex ) and semaphore in the Platform SDK. Boost also has a pretty sweet barrier. The terms will make sense once you check out that book. That's all I got for ya.
|
# ? Sep 12, 2009 12:40 |
|
Kimani posted:The Little Book of Semaphores is very, very good at presenting the problems associated with parallel programming and the tools used to tackle them. It's language agnostic and should show you all the theory. Too bad mutual exclusion is fundamentally one of the most difficult-to-maintain methods of parallelism* (and these days, one might question the need for manually handling locks when libraries/APIs like TBB and OpenMP exist). For doing "real work" with parallelism, the solution is typically MPI. Granted, this is beginning to change in the high-performance computing world, now that each compute node may has multiple cores of its own, and now that researchers are getting more interested in GPU programming for more than the "can we do it" factor. Also, if you're using C++, you should never ever bother with the Win32 lock constructs unless you are under absolutely insane requirements (e.g. "no CRT dependencies ever"). TR1, which Microsoft has implemented and is available for VS2008, contains a fully standardized C++ threading library, which has also been incorporated into the next draft standard. * In theory, a good static analyzer would help with this, but I'm not sure that one exists, and it's going to take clang a few years before it can even compile C++ well, let alone statically analyze it.
|
# ? Sep 12, 2009 16:45 |
|
Kimani posted:The Little Book of Semaphores is very, very good at presenting the problems associated with parallel programming and the tools used to tackle them. It's language agnostic and should show you all the theory. Sweet, after reading a couple chapters of that book I understood enough to use the Platform SDK implementations to get my video rendering thingy to do different frames at the same time on different CPUs. (An incredibly simple problem to solve, as it turns out, but it was what I had my sights set on originally.) Thanks, guy!
|
# ? Sep 12, 2009 18:22 |
|
I've used helgrind, a part of the excellent valgrind suite to help track down locking problems before. I personally use pthreads for the heavy duty work and OpenMP for simple loop constructs. OpenMP is beginning to get usable now that tasks and recursion can be implemented.
|
# ? Sep 12, 2009 20:55 |
|
I'm using code from this example and having a new issue. Every time the code goes through this section:code:
code:
iSuck fucked around with this message at 04:14 on Sep 15, 2009 |
# ? Sep 13, 2009 08:54 |
|
I'm getting something slightly odd with my STL containers. The problem occurs in the following function callcode:
code:
code:
What the function call is supposed to do is compare two EA2Skeletons by comparing the EA2SkeletonSegments they point to - if two EA2Skeletons point to the the same objects then they're considered equal. The debugger is telling me that I'm dereferencing a past-the-end iterator during the evaluation (not sure if that's the right word) of the second argument to the function. This didn't happen in my testing, and I'm not sure why it's happening or how to fix it. Any thoughts?
|
# ? Sep 15, 2009 01:15 |
|
Why would you not check the length first? Aside from avoiding potential crashes, it'd be faster in most cases.
|
# ? Sep 15, 2009 01:20 |
|
Quick question for anyone who uses scope guards: If you declare a resource release before you obtain it, is it optimized out in release builds? In other words does: code:
I don't have the exact implementation but I'm sure it's pretty similar to Loki or the modified version in the boost archive. I won't have the code again til I'm back in in a few days so I can't test a debug build.
|
# ? Sep 15, 2009 09:01 |
|
Avenging Dentist posted:Why would you not check the length first? Aside from avoiding potential crashes, it'd be faster in most cases. If the surrounding code is working properly then they should both be the same length already, but I'll stick an assert in and see if that catches anything. Edit: Caught it! Messed up a conditional statement earlier on, one of the arguments was of size zero. I need to be more assertive. DoctorTristan fucked around with this message at 09:46 on Sep 15, 2009 |
# ? Sep 15, 2009 09:23 |
|
showdown posted:Quick question for anyone who uses scope guards: How would we know? In addition to not telling us your compiler, you haven't even shown us the implementation of the scope guard you're using. If you want to find out, make a reduced test case and check the assembler output.
|
# ? Sep 15, 2009 16:49 |
|
Another question is why you're not just using RAII instead, since it'd remove the need for any explicit scope resource management
|
# ? Sep 15, 2009 16:53 |
|
The Red Baron posted:Another question is why you're not just using RAII instead, since it'd remove the need for any explicit scope resource management Scope guards are RAII for types you don't control.
|
# ? Sep 15, 2009 17:12 |
|
Avenging Dentist posted:How would we know? In addition to not telling us your compiler, you haven't even shown us the implementation of the scope guard you're using. If you want to find out, make a reduced test case and check the assembler output. Oops. I guess it was wrong to assume everyone on the planet uses Visual Studio I did say it was pretty much Loki SG, though Good idea to check assembly, though, I tested it with Loki and it is in fact optimized to a no-op in release and runs correctly debug
|
# ? Sep 15, 2009 18:19 |
|
Avenging Dentist posted:Scope guards are RAII for types you don't control. I meant in the sense of encapsulating the RAII logic in a auto_handle class rather than having to use a scope guard each time
|
# ? Sep 15, 2009 19:34 |
|
Is there a one stop shop (book/article/something) for RAII best practices? Because as soon as I feel like I know all there is to know about it, something keeps popping up.
|
# ? Sep 15, 2009 21:04 |
|
Does anyone know anything about Boost.Asio? I am still working with a simple client/server socket pair from Boost's website. I've been asked to break everything up into classes so that they can be integrated into another program. However, I'm a bit stumped on how to deal with the client half of things. The "main" class needs two arguments to work. I can't figure out where they are coming from though. There isn't any obvious way that they are passed by the server half. The whole thing just works on its own when you keep them in two separate programs. What am I missing here?
|
# ? Sep 15, 2009 21:46 |
|
HondaCivet posted:Does anyone know anything about Boost.Asio? I am still working with a simple client/server socket pair from Boost's website. I've been asked to break everything up into classes so that they can be integrated into another program. However, I'm a bit stumped on how to deal with the client half of things. The "main" class needs two arguments to work. I can't figure out where they are coming from though. There isn't any obvious way that they are passed by the server half. The whole thing just works on its own when you keep them in two separate programs. What am I missing here? C++ command line arguments
|
# ? Sep 15, 2009 22:16 |
|
Commander Keen posted:C++ command line arguments Cool, had no idea about those. I'm still new to programming. Thanks!
|
# ? Sep 15, 2009 23:16 |
|
I am a dumb newbie when it comes to C++ and I must be looking in the completely wrong places, but I just cannot figure out how to input a txt of varying integers into a simple array in C++. I figured out how to have the program ask you the number of integers being inputted, but I need to have the program to work if the user does not know the actual number of lines in the file. The txt file would look similar to this... 1 4 2 5 7 3 5
|
# ? Sep 16, 2009 18:15 |
|
code:
|
# ? Sep 16, 2009 19:13 |
|
Thank you.
|
# ? Sep 17, 2009 16:20 |
|
Why does this:code:
code:
I've been getting back into basic programming in something other than Matlab for the first time since first year undergrad, and it was going great until I needed to input floating point numbers. I'm using Visual C++ 2008 Express (compiling as C) if that makes any difference. If someone could point out what I'm missing I'd very much appreciate it!
|
# ? Sep 20, 2009 01:45 |
|
Kreez posted:
|
# ? Sep 20, 2009 01:46 |
|
Scaevolus posted:%f means float, not double. (use %lf) EDIT: Oh, you mean scanf.
|
# ? Sep 20, 2009 01:52 |
|
Cool, %lf works great, thanks. Odd that something basic like that would be left out of even the basic C syntax overview that exists in my textbook.
|
# ? Sep 20, 2009 02:04 |
|
Kreez posted:Cool, %lf works great, thanks.
|
# ? Sep 20, 2009 02:31 |
|
Posting this in here, since I'm using C and I didn't see a thread on win32. I'm taking an intro to win32 course in college, and I can't figure out what the purpose of the cbSize member is in a struct. I googled it, and there were a couple of suggestions like "used for different versions of a struct", and "used for a struct with variable length data", but I'm not sure of the official reason, though the second one seems to make a bit more sense to me.
|
# ? Sep 21, 2009 21:08 |
|
w00tz0r posted:I googled it, and there were a couple of suggestions like "used for different versions of a struct", and "used for a struct with variable length data", but I'm not sure of the official reason, though the second one seems to make a bit more sense to me. It's more the former than the latter. As new versions of Windows are released, Microsoft adds new members to structs, and the cbSize parameter helps them figure out which version of the API your binary uses for that particular function. That way they don't go accessing unallocated memory when trying to query the new members and potentially segfaulting or doing something completely random*. * Not completely random.
|
# ? Sep 21, 2009 21:11 |
|
Avenging Dentist posted:It's more the former than the latter. As new versions of Windows are released, Microsoft adds new members to structs, and the cbSize parameter helps them figure out which version of the API your binary uses for that particular function. That way they don't go accessing unallocated memory when trying to query the new members and potentially segfaulting or doing something completely random*. Awesome, thanks. Our instructor mentioned it in class, and then asked us why we thought Microsoft did it. This was followed by about 5 minutes of awkward silence and wrong answers as he waited for us to tell him, then he told us to find out on our own time.
|
# ? Sep 21, 2009 23:13 |
|
Hi CoC, I have a C++ question specifically tied to the NetBeans IDE. Is there a way to use my source files from one project in another project? I do not wish to have multiple copies of the same file in several location, god forbid I need to change one thing from a single class, and now have to change it in every project that used it. I've tried playing around with the project settings myself, and google does not seem to give me exactly what I'm looking for. Any ideas goons? Thank you, FearIt
|
# ? Sep 23, 2009 13:32 |
|
FearIt posted:Hi CoC, do what you would do in any other language - make a library out of your project that you want to reuse in another project. Of course you have to recompile the library every time you make changes to the source code.
|
# ? Sep 23, 2009 15:55 |
|
This is more rhetorical, but does dealing with ansi/unicode (and the various kinds of strings and poo poo in general) in C++ make anyone else want to cut their own dick off? My god I hate it so much.
|
# ? Sep 23, 2009 21:18 |
|
|
# ? Jun 8, 2024 06:25 |
|
Argh, I'm getting this weird nasty runtime error and I can't imagine what would be causing it. When I try to run my program, I get this scary window that says "Debug Assertion Failed!" and a bunch of stuff. The problem is in TimingTest.exe (something in Windows I assume) and it is mentioning an invalid null pointer. What sorts of things should I be looking for to figure this error out? I'm pretty sure it's in here. (Warning: Boost.Asio ahead)
|
# ? Sep 23, 2009 22:59 |